guillermo-navas-palencia / optbinning

Optimal binning: monotonic binning with constraints. Support batch & stream optimal binning. Scorecard modelling and counterfactual explanations.
http://gnpalencia.org/optbinning/
Apache License 2.0
459 stars 100 forks source link

How to get split points of fitted ContinuousOptimalBinning class on categorical variable #341

Closed Kovo121 closed 3 days ago

Kovo121 commented 1 week ago

I'm trying to use optimal binning on a continuous target variable and a categorical feature. I've noticed that the "splits" property returns the binned input categories, but it doesn't provide the target mean split points used to create these bins. Is there a way to retrieve these split points?

guillermo-navas-palencia commented 6 days ago

Hi @Kovo121.

Yes, this is hidden, but you can retrieve them via "self._splits_optimal".

guillermo-navas-palencia commented 3 days ago

Could you please confirm and close the issue? Thanks @Kovo121

Kovo121 commented 3 days ago

Hi @guillermo-navas-palencia . After looking into it more, I found out that self._splits_optimal isn’t actually the target mean split points. Instead, it’s a listof indices pointing to a list of categories sorted by their target variable means. With that figured out, I was able to identify the actual target mean split points.