# Special values¶

You might have some features with values that you need to have in a separate bucket. You can define a dictionary with the buckets you want, and pass them to the bucketer.

In the example below, the special values for the variable "EDUCATION" are put into a separate bucket, -3. Note that this bucket is not included in the n_bins parameter

from skorecard.bucketers import EqualWidthBucketer

specials = {
"LIMIT_BAL": {"=50000": [50000], "in [20001,30000]": [20000, 30000]},
"EDUCATION": {"=High School, Graduate School": [1, 3]}
}

cols = ['LIMIT_BAL', 'EDUCATION']
X_transformed = EqualWidthBucketer(n_bins=3, specials=specials, variables=cols).fit_transform(X, y)
X_transformed['EDUCATION'].value_counts()

-3    3199
0    2726
2      62
1      13
Name: EDUCATION, dtype: int64


Last update: 2021-11-24