-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Add quantile loss as metric #18911
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
also ping @GaelVaroquaux (just to let you know) as we coincidentally exchanged about that yesterday. |
We would also need to document how to register this use this as a scorer to be able to do model selection on quantile regressors: from sklearn.metrics import quantile_loss, make_scorer
neg_90_percentile_loss = make_scorer(
quantile_loss,
higher_is_better=False,
alpha=0.9,
)
...
search_cv = GridSearchCV(
quantile_regressor,
param_grid,
scoring=neg_05_percentile_loss,
cv=5
)
search_cv.fit(X_train, y_train) |
After a cursory look at the reference above, I have the impression that it states that the alpha-quantile loss is a useful surrogate loss, in the sense that minimizing it gives a consistent estimate of alpha-quantiles, but not a calibrated metric, in the sens that I can compare two models of a different family of models using it. This is similar to the logistic loss, which is a surrogate for the zero-one classification loss. Am I wrong? Are there theoretical arguments for using values of alpha-quantile loss as a metric across models? Thanks! |
Note that my comment probably does not rule out the use of the alpha-quantile loss as a metric in GridSearchCV, because surrogate losses can be useful to compare models close enough. I would worry when using it to evaluate a model before putting it in production. |
Yes, the (alpha-) quantile loss gives strictly consistent (Fisher consistency) estimates of the true (alpha-) quantile. It is, in my understanding, very suitable to compare different models' predictions/forecasts (of the true conditional alpha-quantile), as is log-loss for probabilistic forecasts/predictions of binary events (actually, I much prefer log-loss over zero-one loss/accuracy if applicable= What exactly do you mean by calibration and surrogate loss? *For binary events, the having the expectation is equivalent of having the whole distribution. |
Surrogate loss = loss that you can minimize (eg because it is differentiable) and serves as a proxy of the actual error measure that you are interested in. The hinge loss and the logistic loss are two surrogates of the zero-one classification error. But comparing two models based on there logistic loss does guarrantie that the best performer will also give the smallest zero-one classification error. You state that the quantile loss is well suited for out-of-sample comparison of different models. Do you have a paper / a theoretical argument that establishes this? For the log loss, I actually am pretty certain that it is not advised to conclude on zero-one classification error after comparing log losses. For the MSE, it is different: squared error is, at the sample level, an unbiased estimate of the distance to the expectation. So summing squared errors (as with MSE) gives an unbiased estimate of the error to the conditional expectation. I do not know a similar result for conditional quantile. But again, I may have missed something. |
🤔 Let's focus on regression to make things easier. The above given reference Making and Evaluating Point Forecasts is about point forecast comparison. All you have to do is to translate it to a regression setting. (Some dictionary: Replace forecaster by model, forecast by model prediction. Note that forecasts are evaluated out-of-sample, so to speak.)
So, any strictly consistent scoring function (for a functional of interest like a quantile) is suited for:
For goodness of fit (focus on in-sample), have a look at "Goodness of Fit and Related Inference Processesfor Quantile Regression", R. Koenker, J. A. Machado, http://dx.doi.org/10.1080/01621459.1999.10473882, free PDF. |
I am not sure if we should name it Estimating conditional quantiles with the help of the pinball loss By googling, I also found about this recent paper which seems relevant to this discussion: Beyond Pinball Loss: Quantile Methods for Calibrated Uncertainty Quantification The new method introduced in this paper is too recent to be considered for inclusion in scikit-learn but I think that might be an interesting reference on how (some) researchers consider the problem of evaluating models for conditional quantile prediction. |
@ogrisel I'm fine with calling it Indeed, there are infinitely many strictly consistent scoring functions of the quantile, all having the form, see paper cited above: S(y, x) = (1_(x ≥ y) − α) (g(x) − g(y)) and g(x) a strictly increasing function. I know, you only googled, but I'm not that convinced of arxiv:2011.09588. |
hello friends for other than GBM lets say categorical data encoded to one hot then it will be It would be great to apply pinball-loss |
Have a look at #18997. |
@lorentzenchr hello friends 6 months pasts , but still it is not clear where to use pinball-loss except GradientBoostingRegressor |
Linear Quantile regression is also implemented in QuantileRegressor Please note that this is a user question, and that pinging developers on an issue to ask a user question is not very good practice (we are overwhelmed with requests). Best |
great thanks for answer 1 Thank you very much in advance for answer |
@Sandy4321 this issue is closed and you are asking a general question. Please open a github Discussions for general questions. Thanks for your understanding. |
Describe the workflow you want to enable
I'd like to evaluate and compare the predictive performance of (conditional) quantiles as predicted by
GradientBoostingRegressor(loss='quantile', alpha=0.9)
for example.Describe your proposed solution
Implement a new metric
quantile_loss(y_true, y_pred, alpha=0.5)
, Eq. (24) of https://arxiv.org/pdf/0912.0902.pdf.This is the same loss as in Koenker's book "Quantile Regression" and in:
scikit-learn/sklearn/ensemble/_gb_losses.py
Lines 461 to 467 in ad3c288
The text was updated successfully, but these errors were encountered: