-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix R dart prediction and add test. #5204
Conversation
I tested this PR with my code at the issue and I'm afraid it might not suffice. First, with |
53d78e6
to
922ffb7
Compare
@Kodiologist Try to use Will keep looking into it. |
@Kodiologist Indeed, using library(xgboost)
set.seed(15)
d <- cbind(
x1 = rnorm(100),
x2 = rnorm(100),
x3 = rnorm(100))
y <- d[,"x1"] + d[,"x2"]^2 +
ifelse(d[,"x3"] > .5, d[,"x3"]^2, 2^d[,"x3"]) +
rnorm(100)
nrounds <- 30
dtrain <- xgb.DMatrix(data=d, info = list(label=y))
params <- list(
verbose = 0,
booster = "dart",
objective = "reg:squarederror",
eval_metric = "rmse",
rate_drop = .5,
nthread = 1,
one_drop = TRUE
)
fit <- xgb.train(
params,
data = dtrain,
nrounds = nrounds)
xgb.save(fit, 'model_after.json')
pr <- function(...) {
predict(fit, newdata = d, ...)
}
cat("w/o ntreelimit\n")
print(pr())
cat("with ntreelimit\n")
print(pr(ntreelimit = nrounds))
print("With training.")
print(pr(training=T)) generates:
Which is consistent with current PR. |
Also |
@Kodiologist Would you like to take another look? |
I see; thanks for explaining about |
That |
@Kodiologist Will do. I'm sorry for causing these many troubles. |
@hcho3 ping |
Aside: I'd like to get my feet wet in the R ecosystem. The XGBoost R package can use more love. Also noticed that large portion of work in statistics and quantitative science is done with R. |
Closes #5203 .