interpret icon indicating copy to clipboard operation
interpret copied to clipboard

How the final number of bins is defined?

Open vinacmg opened this issue 4 years ago • 3 comments

Hi! I can see that there is a max_bins parameter, however, I can't figure out how the final number is defined. Could you explain it to me, please? Kind regards, V.

vinacmg avatar Mar 18 '22 21:03 vinacmg

max_bins only applies to continuous features. Under the default 'quantile' binning, we attempt to discretize continuous features into bins with approximately equal numbers of samples. Generally, if you get significantly less bins than max_bins it means your feature doesn't have sufficient numbers of unique values to create that many bins. The quantile binning algorithm is a heuristic however, and there are edge cases where you can have sufficient numbers of unique values in your dataset, but you still get less than max_bins bins. If you use 'uniform' binning instead of 'quantile', you'll almost always get the same number of bins as your max_bins parameter since it just divides up the space between the max and min values for the feature, even if there are no samples within some of the bins.

-InterpretML team

interpret-ml avatar Mar 18 '22 22:03 interpret-ml

First, thank you for the reply! So the final number of bins is a fixed number across all features (even if just one feature doesn't have sufficient numbers) or is it a per feature number?

vinacmg avatar Mar 19 '22 01:03 vinacmg

max_bins is a single number that applies to all continuous features, but quantile binning is run on each feature independently and the number of bins you get from that varies across features depending on how many unique values each feature has and other considerations.

-InterpretML team

interpret-ml avatar Apr 04 '22 19:04 interpret-ml