scikit-learn-contrib / MAPIE

A scikit-learn-compatible module to estimate prediction intervals and control risks based on conformal predictions.
https://mapie.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
1.2k stars 99 forks source link

alpha values for model vs MapieQuantileRegressor #388

Closed Ciaran1981 closed 6 months ago

Ciaran1981 commented 6 months ago

More of a question than an issue related to one of the demos (plot cqr). Why is the alpha parameter set to 0.5 in the lgb model, whereas in the MapieQuantileRegressor it is set to 0.2.

In the model alpha specifies which quantile to be estimated - shouldn't the lgb also be set to 0.2? Can someone explain why the lgb and MQR have different alpha values.

thibaultcordier commented 6 months ago

Hello @Ciaran1981,

What an excellent question! I'll try to be as precise as possible.

TL;DR

There are two types of alpha for two types of use, depending on whether you configure the predictive model (alpha=0.5, or median) or the quantile model (alpha=0.1 or something close to 0).

About the demo

The alpha parameter is set to 0.5 in the lgb model because we are initialising the prediction model. Instead of using the mean, we use the median, which is why we set objective='quantile' and alpha=0.5.

About MapieQuantileRegressor

In the initialization of the MapieQuantileRegressor object, we need to specify the target risk before we can be sure that the quantile regressor will be adjusted to the correct quantile. This is why we set it to alpha=0.1.

In the code, MAPIE clones 3 estimators, (1) the prediction model which is the lgb model initialised with alpha=0.5 to estimate the median, (2/3) the lower/higher quantile models which are cloned from the lgb model but with the correct quantiles alpha=0.1/2 and alpha=(1-0.1)/2 relative to the given alpha.

I hope I have answered your question. Please let me know if this answer satisfies you.

Ciaran1981 commented 6 months ago

Yes thanks.