-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
Description
Summary
The Dask estimators in lightgbm.dask should support the use of a custom objective function.
Motivation
This feature would bring Dask estimators closer to parity with the sklearn estimators.
Description
I haven't thought through this much yet, just writing up a placeholder issue for discussion. If you're reading this and have ideas, please comment and the issue can be re-opened.
References
See
LightGBM/python-package/lightgbm/sklearn.py
Lines 430 to 453 in 15916a9
| A custom objective function can be provided for the ``objective`` parameter. | |
| In this case, it should have the signature | |
| ``objective(y_true, y_pred) -> grad, hess`` or | |
| ``objective(y_true, y_pred, group) -> grad, hess``: | |
| y_true : array-like of shape = [n_samples] | |
| The target values. | |
| y_pred : array-like of shape = [n_samples] or shape = [n_samples * n_classes] (for multi-class task) | |
| The predicted values. | |
| group : array-like | |
| Group/query data. | |
| Only used in the learning-to-rank task. | |
| sum(group) = n_samples. | |
| For example, if you have a 100-document dataset with ``group = [10, 20, 40, 10, 10, 10]``, that means that you have 6 groups, | |
| where the first 10 records are in the first group, records 11-30 are in the second group, records 31-70 are in the third group, etc. | |
| grad : array-like of shape = [n_samples] or shape = [n_samples * n_classes] (for multi-class task) | |
| The value of the first order derivative (gradient) for each sample point. | |
| hess : array-like of shape = [n_samples] or shape = [n_samples * n_classes] (for multi-class task) | |
| The value of the second order derivative (Hessian) for each sample point. | |
| For binary task, the y_pred is margin. | |
| For multi-class task, the y_pred is group by class_id first, then group by row_id. | |
| If you want to get i-th row y_pred in j-th class, the access way is y_pred[j * num_data + i] | |
| and you should group grad and hess in this way as well. |
Can look at how xgboost.dask handles this for inspiration:
Reactions are currently unavailable