|
60 | 60 | # As a baseline, we could use a classifier which will always predict the |
61 | 61 | # majority class independently of the features provided. |
62 | 62 |
|
| 63 | +from sklearn.dummy import DummyClassifier |
| 64 | + |
63 | 65 | # %% |
64 | 66 | from sklearn.model_selection import cross_validate |
65 | | -from sklearn.dummy import DummyClassifier |
66 | 67 |
|
67 | 68 | dummy_clf = DummyClassifier(strategy="most_frequent") |
68 | 69 | scoring = ["accuracy", "balanced_accuracy"] |
|
121 | 122 |
|
122 | 123 | # %% |
123 | 124 | from sklearn.impute import SimpleImputer |
124 | | -from sklearn.preprocessing import StandardScaler |
125 | | -from sklearn.preprocessing import OneHotEncoder |
126 | 125 | from sklearn.pipeline import make_pipeline |
| 126 | +from sklearn.preprocessing import OneHotEncoder, StandardScaler |
127 | 127 |
|
128 | 128 | num_pipe = make_pipeline( |
129 | 129 | StandardScaler(), SimpleImputer(strategy="mean", add_indicator=True) |
|
139 | 139 | # numerical pipeline |
140 | 140 |
|
141 | 141 | # %% |
142 | | -from sklearn.compose import make_column_transformer |
143 | 142 | from sklearn.compose import make_column_selector as selector |
| 143 | +from sklearn.compose import make_column_transformer |
144 | 144 |
|
145 | 145 | preprocessor_linear = make_column_transformer( |
146 | 146 | (num_pipe, selector(dtype_include="number")), |
|
176 | 176 | # classifier, we will not need to scale the numerical data, and we will only |
177 | 177 | # need to ordinal encode the categorical data. |
178 | 178 |
|
| 179 | +from sklearn.ensemble import RandomForestClassifier |
| 180 | + |
179 | 181 | # %% |
180 | 182 | from sklearn.preprocessing import OrdinalEncoder |
181 | | -from sklearn.ensemble import RandomForestClassifier |
182 | 183 |
|
183 | 184 | num_pipe = SimpleImputer(strategy="mean", add_indicator=True) |
184 | 185 | cat_pipe = make_pipeline( |
|
336 | 337 | # applying a single random under-sampling. We will use a gradient-boosting |
337 | 338 | # classifier within a :class:`~imblearn.ensemble.BalancedBaggingClassifier`. |
338 | 339 |
|
339 | | -from sklearn.experimental import enable_hist_gradient_boosting # noqa |
340 | 340 | from sklearn.ensemble import HistGradientBoostingClassifier |
| 341 | +from sklearn.experimental import enable_hist_gradient_boosting # noqa |
| 342 | + |
341 | 343 | from imblearn.ensemble import BalancedBaggingClassifier |
342 | 344 |
|
343 | 345 | bag_clf = make_pipeline( |
|
0 commit comments