-
-
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
Custom multiclass objective receives transformed predictions #4288
Comments
I'm working on a multiclass classification problem using a custom objective function, where I use the probabilities of each class. |
@kaijennissen Take a look at the example at
|
I don't see how to put the custom_predict function into the evaluation. Can you help? |
@guyko81 Could you please open a new issue I can track for adding demo? |
@trivialfis I just opened, thanks in advance! |
Hi, I have read the link you paste. I have a question about it, I think the hessian should be a matrix of (class_num, class_num) but not a vector? |
Hi,
I'm having issues with custom multiclass objective function receiving transformed predictions. The problem has already been raised in issue #2776
I believe the objective function should expect
preds
as a (N, K) array, N = #data, K = #classes, but it's not the case by default in both python and R. The previous issue points toxgboost/src/objective/multiclass_obj.cu
Lines 154 to 157 in 263e203
In python, I managed to get the correct
preds
shape by adding'objective': 'multi:softprob'
to the parameters on top of my custom objective function. Here is a MWE:Created on 2019-03-22 by the reprexpy package
The R package will not allow to use the same trick:
Created on 2019-03-22 by the reprex package (v0.2.1)
A solution is to modify this line of
xgb.iter.update
:xgboost/R-package/R/utils.R
Line 148 in 263e203
as:
Moreover, we need to apply softmax to predictions since we cannot "force" softprob.
MWE reproducing the python example:
Created on 2019-03-22 by the reprex package (v0.2.1)
The long term solution would be to modify the native c++ code but it's beyond my expertise.
The text was updated successfully, but these errors were encountered: