Skip to content

Commit 0bcc6dd

Browse files
authored
Merge pull request #338 from tidymodels/xgb-objective
Use reg:squarederror objective for xgboost
2 parents b895a56 + b0789d1 commit 0bcc6dd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

R/boost_tree.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ xgb_train <- function(
301301

302302

303303
if (is.numeric(y)) {
304-
loss <- "reg:linear"
304+
loss <- "reg:squarederror"
305305
} else {
306306
lvl <- levels(y)
307307
y <- as.numeric(y) - 1
@@ -399,7 +399,7 @@ xgb_pred <- function(object, newdata, ...) {
399399

400400
x = switch(
401401
object$params$objective,
402-
"reg:linear" = , "reg:logistic" = , "binary:logistic" = res,
402+
"reg:squarederror" = , "reg:logistic" = , "binary:logistic" = res,
403403
"binary:logitraw" = stats::binomial()$linkinv(res),
404404
"multi:softprob" = matrix(res, ncol = object$params$num_class, byrow = TRUE),
405405
res

0 commit comments

Comments
 (0)