<jupyter_start><jupyter_text>Import<jupyter_code># Basic
import pandas as pd
import numpy as np

import warnings
warnings.simplefilter('ignore')

# Data
from catboost.datasets import adult

# ML Toolkit
from robusta.preprocessing import *
from robusta.pipeline import *
from robusta.crossval import *
from sklearn.metrics import *

# Model
from robusta.testing import get_estimator

%load_ext memory_profiler<jupyter_output>Using TensorFlow backend.<jupyter_text>Data<jupyter_code>TARGET = 'income'

train, test = adult()

# Target
y_train = train.pop(TARGET)
y_test = test.pop(TARGET)

# Target Binarization
lb = LabelBinarizer()

y_train = lb.fit_transform(y_train)
y_test = lb.transform(y_test)
train
y_train<jupyter_output><empty_output><jupyter_text>Task & Model<jupyter_code>cv = 5
scoring = 'roc_auc'
estimator = get_estimator('LogisticRegression')
estimator<jupyter_output><empty_output><jupyter_text>Baseline<jupyter_code>prep_pipe = make_pipeline(
    TypeSelector(np.number),
)

X_train = prep_pipe.fit_transform(train)
X_test = prep_pipe.transform(test)

X_train
_ = crossval(estimator, cv, X_train, y_train, scoring=scoring)<jupyter_output>[04:34:28]  LogisticRegression

[04:34:28]  FOLD  0:   0.5852
[04:34:29]  FOLD  1:   0.6043
[04:34:29]  FOLD  2:   0.5825
[04:34:29]  FOLD  3:   0.5690
[04:34:29]  FOLD  4:   0.5891

[04:34:29]  AVERAGE:   [33m0.5860[0m ± 0.0114<jupyter_text>One-Hot-Encoding<jupyter_code>prep_pipe = make_pipeline(
    TypeSelector(np.number),
    KBinsDiscretizer(20),
    DummyEncoder()
)

X_train = prep_pipe.fit_transform(train)
X_test = prep_pipe.transform(test)

X_train
_ = crossval(estimator, cv, X_train, y_train, scoring=scoring)<jupyter_output>[04:34:29]  LogisticRegression

[04:34:29]  FOLD  0:   0.8494
[04:34:29]  FOLD  1:   0.8470
[04:34:29]  FOLD  2:   0.8568
[04:34:29]  FOLD  3:   0.8554
[04:34:29]  FOLD  4:   0.8598

[04:34:30]  AVERAGE:   [33m0.8537[0m ± 0.0047<jupyter_text>Thermometer Encoding<jupyter_code>prep_pipe = make_pipeline(
    TypeSelector(np.number),
    KBinsDiscretizer(20),
    ThermometerEncoder(),
)

X_train = prep_pipe.fit_transform(train)
X_test = prep_pipe.transform(test)

X_train
_ = crossval(estimator, cv, X_train, y_train, scoring=scoring)<jupyter_output>[04:34:30]  LogisticRegression

[04:34:31]  FOLD  0:   0.8497
[04:34:31]  FOLD  1:   0.8473
[04:34:31]  FOLD  2:   0.8570
[04:34:31]  FOLD  3:   0.8556
[04:34:31]  FOLD  4:   0.8600

[04:34:31]  AVERAGE:   [33m0.8539[0m ± 0.0047
{'fraction_non_alphanumeric': 0.12964458804523424, 'fraction_numerical': 0.1050080775444265, 'mean_word_length': 5.367609254498714, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '528470', 'license': 'MIT', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1082, 'n_words': 186, 'path': 'examples/preprocessing-thermometer.ipynb', 'repo_name': 'uberkinder/Robusta-AutoML', 'size': '2476'}