yasc.scorecard.mono_bin

yasc.scorecard.mono_bin(Y, X, n=20, precision=3, duplicates='raise')

Generate monotonous bins.

Parameters
YSeries

A series of labels.

XSeries

The series to bin, it should be of numeric type.

nint or list-like of int, optional

Number of quantiles, by default 20

precisionint, optional

The precision at which to store and display the bins labels, by default 3

duplicatesstr, optional

Argument used by pandas.qcut(), by default “raise”

Returns
DataFrame

Descriptive statistics of binning.

Examples

>>> from yasc.data import german_data
>>> from yasc.scorecard import mono_bin
>>> import pandas as pd; pd.set_option('max_columns', None)
>>> data = german_data()
>>> mono_bin(data.Creditability, data.DurationInMonth, duplicates='drop')
>>> bin_stat
               min  max  bad_count  good_count  total  bad_rate  good_rate  \
Bucket
(3.999, 12.0]    4   12         76         283    359  0.253333   0.404286
(12.0, 24.0]    13   24        122         289    411  0.406667   0.412857
(24.0, 72.0]    26   72        102         128    230  0.340000   0.182857
                    woe        iv    iv_sum                     bins
Bucket
(3.999, 12.0] -0.467416  0.070558  0.168117  [-inf, 12, 24, 72, inf]
(12.0, 24.0]  -0.015108  0.000094  0.168117  [-inf, 12, 24, 72, inf]
(24.0, 72.0]   0.620240  0.097466  0.168117  [-inf, 12, 24, 72, inf]