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
from skorecard.datasets import load_uci_credit_card
X, y = load_uci_credit_card(return_X_y=True)
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()