You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request: support for arbitrary bin spacing in calibration.calibration_curve #13086
I was using sklearn.calibration.calibration_curve, and it currently accepts an n_bins parameter to specify the number of bins to evenly partition the probability space between 0 and 1.
However, I am using this in combination with a gradient boosting model in which the probabilities are very uncalibrated, and most of the predictions are close to 0. When I use the calibrated classifier, the result is very noisy because there are many data points in some bins and few, if any, in others (see example below).
In the code below, I made a work-around to do what I want and show a plot of my output (in semilog space because of the skewed distribution). I haven't contributed to a large open-source project before, but if there's agreement this would be a useful feature, I would be happy to try to draft up a PR.
Notice the large disparity in results between the different bins chosen. For this reason, I think the user should be able to choose the bin edges, as in numpy's or matplotlib's histogram functions.
Yup, quantile bins would have my desired effect. I just thought it would be nice to allow more flexibility by allowing a bins parameter, but I suppose it's not necessary.
I think this still satisfies "calibration curve." I don't see any reason that a "calibration" needs to have evenly-spaced bins. Often it's natural to do things in a log-spaced manner.
Activity
jnothman commentedon Feb 4, 2019
jnothman commentedon Feb 4, 2019
srcole commentedon Feb 4, 2019
Yup, quantile bins would have my desired effect. I just thought it would be nice to allow more flexibility by allowing a
binsparameter, but I suppose it's not necessary.I think this still satisfies "calibration curve." I don't see any reason that a "calibration" needs to have evenly-spaced bins. Often it's natural to do things in a log-spaced manner.
jnothman commentedon Feb 4, 2019
I'm happy to see a pr for quantiles here
srcole commentedon Feb 4, 2019
Sweet. I'll plan to do work on it next weekend