Skip to content
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

XGBoost V.2.0.2 does not recognize 'reg:quantileerror' as a valid objective function #9912

Closed
georgi72 opened this issue Dec 20, 2023 · 15 comments

Comments

@georgi72
Copy link

import xgboost as xgb

xgb.version
Out[203]: '2.0.2'

booster = xgb.train(
{
# Use the quantile objective function.
"objective": "reg:quantileerror",
"tree_method": "hist",
"quantile_alpha": alpha,
# Let's try not to overfit.
"learning_rate": 0.04,
"max_depth": 5,
},
Xy,
num_boost_round=32,
early_stopping_rounds=2,
# The evaluation result is a weighted average across multiple quantiles.
evals=[(Xy, "Train"), (Xy_test, "Test")],
evals_result=evals_result,
)

XGBoostError: [11:04:05] C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-08de971ced8a8cdc6-1\xgboost\xgboost-ci-windows\src\objective\objective.cc:26: Unknown objective function: reg:quantileerror

According to the documentation, quantile error is implemented in v.2.0.2. What am I missing? Thank you.

@hcho3
Copy link
Collaborator

hcho3 commented Dec 20, 2023

How did you install XGBoost? I could not reproduce the error when I installed XGBoost 2.0.3 using pip install xgboost.

@georgi72
Copy link
Author

I used "conda install -c conda-forge py-xgboost".

Now I upgraded to v.2.0.3 using "pip3 install xgboost==2.0.3" and get the same error.

@hcho3
Copy link
Collaborator

hcho3 commented Dec 20, 2023

Can you install XGBoost again? It appears that your XGBoost installation is somehow corrupted.

@georgi72
Copy link
Author

I uninstalled and reinstalled xgboost using "pip install xgboost". The version is 2.0.3. I get the same result. Not sure what is going on.

@trivialfis
Copy link
Member

Could you please print out the XGB version before the training code?

import xgboost
print(xgboost.__version__)


...



booster = xgb.train(
{
# Use the quantile objective function.
"objective": "reg:quantileerror",
"tree_method": "hist",
"quantile_alpha": alpha,
# Let's try not to overfit.
"learning_rate": 0.04,
"max_depth": 5,
},
Xy,
num_boost_round=32,
early_stopping_rounds=2,
# The evaluation result is a weighted average across multiple quantiles.
evals=[(Xy, "Train"), (Xy_test, "Test")],
evals_result=evals_result,
)

@georgi72
Copy link
Author

import xgboost
print(xgboost.version)
2.0.3

@trivialfis
Copy link
Member

Could you please share the complete error message?

@georgi72
Copy link
Author

XGBoostError: [06:08:55] C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-08de971ced8a8cdc6-1\xgboost\xgboost-ci-windows\src\objective\objective.cc:26: Unknown objective function: reg:quantileerror
Objective candidate: survival:aft
Objective candidate: binary:hinge
Objective candidate: multi:softmax
Objective candidate: multi:softprob
Objective candidate: rank:pairwise
Objective candidate: rank:ndcg
Objective candidate: rank:map
Objective candidate: survival:cox
Objective candidate: reg:gamma
Objective candidate: reg:tweedie
Objective candidate: reg:squarederror
Objective candidate: reg:squaredlogerror
Objective candidate: reg:logistic
Objective candidate: binary:logistic
Objective candidate: binary:logitraw
Objective candidate: reg:linear
Objective candidate: reg:absoluteerror
Objective candidate: reg:pseudohubererror
Objective candidate: count:poisson

@trivialfis
Copy link
Member

@hcho3 Did you try it on Windows? I don't understand why the objective isn't registered.

@georgi72
Copy link
Author

Yes, I am working in Windows. I don't understand either.

@hcho3
Copy link
Collaborator

hcho3 commented Dec 22, 2023

I just tried running demo/guide-python/quantile_regression.py on Windows and could not reproduce the error either. I installed XGBoost 2.0.3 using pip install xgboost.

@joranE
Copy link

joranE commented Apr 6, 2024

I don't know if they are related, but using the R package (v1.7.7.1 binary from CRAN) when I attempt to use reg:quantileerror I also get an error that it is an unrecognized objective:

library(xgboost)

y <- mtcars$mpg
X <- as.matrix(mtcars[,-1])

res <- xgboost(
  data = X,
  label = y,
  nrounds = 100,
  params = list(objective = "reg:quantileerror",alpha = c(0.1,0.5,0.9))
)

yields this error:

Error in xgb.iter.update(bst$handle, dtrain, iteration - 1, obj) : 
  [15:19:47] src/objective/objective.cc:26: Unknown objective function: `reg:quantileerror`
Objective candidate: reg:squarederror
Objective candidate: reg:squaredlogerror
Objective candidate: reg:logistic
Objective candidate: binary:logistic
Objective candidate: binary:logitraw
Objective candidate: reg:linear
Objective candidate: reg:pseudohubererror
Objective candidate: count:poisson
Objective candidate: survival:cox
Objective candidate: reg:gamma
Objective candidate: reg:tweedie
Objective candidate: reg:absoluteerror
Objective candidate: multi:softmax
Objective candidate: multi:softprob
Objective candidate: rank:pairwise
Objective candidate: rank:ndcg
Objective candidate: rank:map
Objective candidate: binary:hinge
Objective candidate: survival:aft

Stack trace:
  [bt] (0) 1   xgboost.so                          0x0000000129009e3c dmlc::LogMessageFatal::~LogMessageFatal() + 124
  [bt] (1) 2   xgboost.so                          0x0000000129030970 xgboost::ObjFunction::Create(st

The stack trace is cut off as I've shown it, there isn't anything more printed to the console.

Specifying another optional objective function, e.g. reg:absoluteerror runs fine with no errors.

@trivialfis
Copy link
Member

R is on 1.7.x, which doesn't include quantile function yet. We are working on the R interface, see #9810 .

@taoari
Copy link

taoari commented May 2, 2024

Same error here for version 2.0.3. The interesting thing is that: if I run pip install xgboost==2.0.3from a notebook, I get this error. But if I run from the system and install the library, this error disappears.

@trivialfis
Copy link
Member

Closing due to unable to reproduce. Feel free to reopen if you can share the environment for debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants