Skip to content

Commit

Permalink
more minor changes to style
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Oct 24, 2019
1 parent 3936709 commit d807aa3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion R-package/R/callback.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ cb.print.evaluation <- function(period = 1) {
i <- env$iteration

# Check if iteration matches moduo
if ((i - 1) %% period == 0 || is.element(i, c(env$begin_iteration, env$end_iteration ))) {
if ( (i - 1) %% period == 0 || is.element(i, c(env$begin_iteration, env$end_iteration))) {

# Merge evaluation string
msg <- merge.eval.string(env)
Expand Down
4 changes: 2 additions & 2 deletions R-package/R/lgb.Booster.R
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Booster <- R6::R6Class(
gpair <- fobj(private$inner_predict(1), private$train_set)

# Check for gradient and hessian as list
if(is.null(gpair$grad) || is.null(gpair$hess)){
if (is.null(gpair$grad) || is.null(gpair$hess)){
stop("lgb.Booster.update: custom objective should
return a list with attributes (hess, grad)")
}
Expand Down Expand Up @@ -635,7 +635,7 @@ Booster <- R6::R6Class(
res <- feval(private$inner_predict(data_idx), data)

# Check for name correctness
if(is.null(res$name) || is.null(res$value) || is.null(res$higher_better)) {
if (is.null(res$name) || is.null(res$value) || is.null(res$higher_better)) {
stop("lgb.Booster.eval: custom eval function should return a
list with attribute (name, value, higher_better)");
}
Expand Down
2 changes: 1 addition & 1 deletion R-package/R/lgb.cv.R
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ lgb.cv <- function(params = list(),
env$eval_list <- merged_msg$eval_list

# Check for standard deviation requirement
if(showsd) {
if (showsd) {
env$eval_err_list <- merged_msg$eval_err_list
}

Expand Down
8 changes: 5 additions & 3 deletions R-package/R/lgb.importance.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ lgb.importance <- function(model, percentage = TRUE) {

# Check if relative values are requested
if (percentage) {
tree_imp_dt[, ":="(Gain = Gain / sum(Gain),
Cover = Cover / sum(Cover),
Frequency = Frequency / sum(Frequency))]
tree_imp_dt[, `:=`(
Gain = Gain / sum(Gain)
, Cover = Cover / sum(Cover)
, Frequency = Frequency / sum(Frequency)
)]
}

# Return importance table
Expand Down
6 changes: 3 additions & 3 deletions R-package/demo/leaf_stability.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ new_data <- data.frame(
, 1 - 1e-15
)
)
new_data$Z <- -(agaricus.test$label * log(new_data$Y) + (1 - agaricus.test$label) * log(1 - new_data$Y))
new_data$Z <- -1 * (agaricus.test$label * log(new_data$Y) + (1 - agaricus.test$label) * log(1 - new_data$Y))
new_data$binned <- .bincode(
x = new_data$X
, breaks = quantile(
Expand Down Expand Up @@ -115,7 +115,7 @@ new_data2 <- data.frame(
, 1 - 1e-15
)
)
new_data2$Z <- -(agaricus.test$label * log(new_data2$Y) + (1 - agaricus.test$label) * log(1 - new_data2$Y))
new_data2$Z <- -1 * (agaricus.test$label * log(new_data2$Y) + (1 - agaricus.test$label) * log(1 - new_data2$Y))
new_data2$binned <- .bincode(
x = new_data2$X
, breaks = quantile(
Expand Down Expand Up @@ -183,7 +183,7 @@ new_data3 <- data.frame(
, 1 - 1e-15
)
)
new_data3$Z <- -(agaricus.test$label * log(new_data3$Y) + (1 - agaricus.test$label) * log(1 - new_data3$Y))
new_data3$Z <- -1 * (agaricus.test$label * log(new_data3$Y) + (1 - agaricus.test$label) * log(1 - new_data3$Y))
new_data3$binned <- .bincode(
x = new_data3$X
, breaks = quantile(
Expand Down
2 changes: 1 addition & 1 deletion R-package/src/install.libs.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if (!use_precompile) {
try_vs <- 0
local_vs_def <- ""
vs_versions <- c("Visual Studio 16 2019", "Visual Studio 15 2017", "Visual Studio 14 2015")
for(vs in vs_versions){
for (vs in vs_versions){
vs_def <- paste0(" -G \"", vs, "\" -A x64")
tmp_cmake_cmd <- paste0(cmake_cmd, vs_def)
try_vs <- system(paste0(tmp_cmake_cmd, " .."))
Expand Down
2 changes: 1 addition & 1 deletion R-package/tests/testthat/test_basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test_that("train and predict binary classification", {

pred1 <- predict(bst, train$data, num_iteration = 1)
expect_equal(length(pred1), 6513)
err_pred1 <- sum((pred1 > 0.5) != train$label) / length(train$label)
err_pred1 <- sum( (pred1 > 0.5) != train$label) / length(train$label)
err_log <- record_results[1]
expect_lt(abs(err_pred1 - err_log), 10e-6)
})
Expand Down

0 comments on commit d807aa3

Please sign in to comment.