-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
API proposal for losses #5044
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
Comments
What do you understand as a loss function? I don't understand 1, 2 and 4. |
Hi, Andreas. By loss function I mean target of optimization, and in many cases this is indeed a formula (mse, logloss). However, the idea of stepwise optimization of GB was many times generalized, probably ranking is good demonstration of this:
|
Thanks for raising the issue @arogozhnikov ! In general, I agree we should improve the API on the loss functions used within our GBRT implementation. This is something I have been thinking about lately as well and I agree we should make it easier for people to plugin new functions if they need to. Currently, doing that is quite cumbersome... I have no opinion yet on how to best do that however -- I'll dig into what you have implemented for hep_ml. CC: @pprett @ndawe @jmschrei who might have opinion on this as well. |
I agree that loss should be an estimator. I have a private boosting implementation with loss being regressor. The fit and predict method correspond to the initial estimate of the gradient boosting algorithm. It allows to fix a lot api issue due to the fact that initial estimator is a mix of inconsistent and non-api compliant estimators. However, @pprett raised previously that fixing that would break the backward compatibility with serialization. This is not worth it if there is no benefit for direct users. |
My thoughts are similar to @arjoly . I am unsure how to handle the backwards compatibility issue, however. I may have a more informative response when I get to that section of the code (still in _tree.pyx). |
For the backward compatibility with serialisation, it's better to have it. But in practice, we make modifications if there are some benefits. Preserving serialisation between versions is a lot of trouble and huge maintenance burden. For the backward compatibility in term of interface (functions, classes, ...), we have the rules to be backward compatible for 2 versions to allow users to adapt. Deprecation warning are raised in the meantime. |
Thanks for working on deduplication of losses in sklearn @lorentzenchr. However cases discussed in this issue are not covered by #15123 I have implemented generic loss for GB in hep_ml a while ago, it covers case of ranking and other losses that use additional information in their formulation. |
You can use
|
@glouppe @ogrisel
I was working on different modifications of gradient boosting with specific loss functions, and unfortunately I was not able to reuse scikit-learn's gradient boosting for my purposes.
My problems are not a reason to change anything in sklearn, but the following concept also resolves other issues (see below).
Loss function is an estimator
For instance, this is useful for different kind or regularization
This means, that loss function has state (and may keep some useful information), or do some heavy precomputations.
Possible benefits
Loss function will become the main logic of algorithm, but this is probably fine, because there are different losses for different problems, which actually makes GB so universal.
Implementation
If you're interested in some details of implementation, you're welcome to see hep_ml.losses sources, there is already an example of ranking loss function.
The text was updated successfully, but these errors were encountered: