Repository navigation
DOC fix calibration user guide and references - #34289
Conversation
|
I think we should keep the references that show the Digging a bit more about this, I think the name for this second problem seems to be "regressograms" rather than "histograms".
I will try to dig a bit further to find if there are earlier proofs for |
|
@ogrisel Those 2 are just the wrong references to cite because they are not the first ones (eg Dimitriadis is 2 years esrlier), and I don’t want scikit-learn to provide them with citation counts. Please not again an endless discussion! |
|
@antoinebaker What‘s your opinion? |
|
@ogrisel We have an estimator called "histogram gradient boosting", the histograms bin features and sum up gradients and hessians. The main point is that I merged the other PR and I should not have done. But I wanted to unblock further development. Maybe @lucyleeow or @betatim can help here. |
|
I think the references to the textbooks (Wassermann or Scott) are too generic, and would require the user to dig in and see the connection with computing the calibration error or estimating the calibration curve. The two cited papers Sun et al Futmani et al are precisely on the topic of the calibration error bias and optimal number of bins, the first reference even has figure 2 to check that the optimal number of bins follows a cube root rule. I think it's good to provide the user with a straightforward reference. It's true that the justification for the cube root rule for the number of bins appears in the Appendix B of [ TDLR: I would personally be in favor of something like: EDIT: maybe the [Sun et al] reference belongs more to the |
|
Thanks @antoinebaker. I added the Dimitriadis reference as you suggested. |
@antoinebaker did not suggest removing Sun et al nor Futmani et al though. |
I think the two are related. I would use the same references for the cube-root rules for all of them. |
|
I digged further, and I found that the optimal cube-root number of bins from the histogram literature (Scott 1979) can indeed be adapted to equal-width regressograms and therefore equal-width binned calibration curves as show in the proof of theorem 7.1 of those lecture notes https://faculty.washington.edu/yenchic/24A_stat535/Lec7_NPregression.pdf The proof was added in 2025 and previous versions of those lecture notes had no proof. The lecture notes refer to All of Nonparametric Statistics by Larry Wasserman but I cannot find this proof there: section 5.2 covers regressograms but without the result on the optimal number of bins and histograms are covered in section 6. The link between the two is not that explicit. Furthermore, the proof in the lecture notes is non-trivial, this is not a peer-reviewed paper and this does not cover the equal-mass binning result (Sun et al precisely consider equal-mass binning case). So to me Sun et al and Futmani et al still deserve to be legitimately referenced here. EDIT: actually there is a weakness in the proof of the lecture notes:
M · μ_M (x) is not a histogram of μ(x) because μ(x) is not a density function so the O(1/M) bias result requires extra assumption. |
I disagree. The proof with histograms more or less carries over 1-1 to "regressograms" (or whatever they are called), In principle, you should convince other core contributors to add a reference. Here, I want to remove one where we (currently) disagree. |
|
I am surprised by the amount of discussion this is generating. As someone who knew nothing about this topic my first thought was "use variable width bins, make sure each one has roughly the same amount of samples in it, use as many bins as you reasonably can without blowing up the uncertainty due to low stats in each bin". So I started skimming through some of the various papers, asking perplexity to summarise some of them, and asked perplexity to do some basic research into where the idea of the cube root comes from (I find that result surprising, why should it be the cube root of the number of samples?). It seems that the reason it is called "rice rule" is because someone at RICE university mentioned that things scale with the cube root in passing in their lecture notes from the middle of the 80s. You arrive at this rule if you want the variance and bias of the quantity you are estimating in the bin to balance/be equal (expressed as a true newbie and hand wavy physicist). The fact that someone put this in lecture notes and didn't bother to write a paper makes me think they thought that this is not a particularly interesting result/not a lot of work went into figuring it out. Dimitriadis 2021 mentions this rule but only to argue for their CORP method is better. They don't give a reference and instead use a few sentences to arrive at the result. This makes me think that this is somehow "standard knowledge" and not a result that had to be discovered. I don't understand enough about the business of calibration to know why it isn't "just" an application of histograms to estimate a quantity. If there is nothing special here then I am surprised someone wrote a paper specifically showing that the cube root rule which is "standard knowledge" for choosing the number of bins if you think that balancing the variance and bias is the thing you want to do. So, as a naive onlooker I think we have bigger fish to fry than discuss who truly was the first to derive and publish a result that 40 years ago was mentioned in some lecture notes. It feels a bit like discussing who to cite when using the formula for the mean squared error (I am sure someone first though of it, but today I would tell people to get lost if they wanted me to cite a particular paper. Or start adding references for using addition, multiplication, etc...) |
|
The bigger fish could be: work on adding a method that does not need binning or make sure that users understand that they need to look at the calibration display's plot with their own eyes and brain turned on, maybe try out a few different values for |
|
@betatim Thanks for your thorough input. Do you have a proposal for this PR? Remove all references (my original proposal)? |
Yes we can do that but the binned calibration curve is the most used tool for calibration evaluation and is actually asymptotically consistent with the cube-root rule. So this is a baseline that deserves being implemented in scikit-learn, irrespective of which reference we cite. The discussion here is about respecting the anteriority of the asymptotic result of the cube root rule. @lorentzenchr states that this is a direct consequence of the cube-root rules of histograms proved asymptotically optimal in Scott 1979 but to me this is not so obvious because a regressograms (like the binned calibration curve is a particular example) and a histogram are two different mathematical objects. I could not find classical references that explicitly prove (or even mention) that property for regressograms. Let me review the original proof again of Scott with Claude to convince myself whether the regressogram results is a direct transposition or not. |
|
I'm not suggesting that we don't include this feature. Like you said, it is useful and I think for many practical use-cases it is a good/very good solution. My recommendation is to include all three references that are currently on the table. Having a handful (less than five) of references seems like a reasonable number to have. It doesn't overwhelm the reader who really wants to know about the nitty gritty. Neither of the references appear off topic to me. Adding an additional reference is free, as long as the total number of references isn't too big and the references are all on topic. We don't have to be the arbiter of what is truly the first/only/authoritative reference. For this particular case it does not feel like we are participating in "SEO for references"/citation farming. My goal is to find a compromise that allows us to move on to other topics. |
I also find it interesting to leverage that discussion to help us reach a shared understanding on the good practice of the impacts of the choice of those parameters in order to improve the educational value of our docstrings and guide the choice of default values. |
|
For the statisticians interested in history: The earliest reference of "regressogram" seems to be Tukey 1961. |
|
For the readers of Annals of Statistics, the asymptotic optimal number of bins was proven by Spiegelman & Sacks (1980) (and others), and summarized (therefore for me a bit easier to read) and generalized by Stone (1982) (a "special invited paper"!). |
|
@ogrisel Is this PR now good for you? |
betatim
left a comment
There was a problem hiding this comment.
I'm fine with the change to the text.
In this case I have no opinion on who we cite or not cite. It seems like one can make a reasonable pro/con each individual reference.
|
@betatim @antoinebaker as just discussed, are you fine? can you merge? |
antoinebaker
left a comment
There was a problem hiding this comment.
I cannot merge but I'm fine with the changes.
|
@antoinebaker Thanks for your approval. Means something to me! |
|
@betatim THX |

Reference Issues/PRs
Follow-up/Oversight of #33856.
What does this implement/fix? Explain your changes.
This PR improves the user guide on
n_binsin calibration curve a bit. In particular, it removes the references.If we want a reference, we should use more original ones, for examples:
AI usage disclosure
None
Any other comments?