|
74 | 74 | # categories.
|
75 | 75 | # * **numerical scaling** numerical features which will be standardized.
|
76 | 76 | #
|
77 |
| -# Now, we create our `ColumnTransfomer` by specifying three values: the |
78 |
| -# preprocessor name, the transformer, and the columns. First, let's create the |
79 |
| -# preprocessors for the numerical and categorical parts. |
| 77 | +# Now, we create our `ColumnTransfomer` using the helper function |
| 78 | +# `make_column_transformer`. We specify two values: the transformer, and the |
| 79 | +# columns. First, let's create the preprocessors for the numerical and |
| 80 | +# categorical parts. |
80 | 81 |
|
81 | 82 | # %%
|
82 | 83 | from sklearn.preprocessing import OneHotEncoder, StandardScaler
|
|
89 | 90 | # their respective columns.
|
90 | 91 |
|
91 | 92 | # %%
|
92 |
| -from sklearn.compose import ColumnTransformer |
| 93 | +from sklearn.compose import make_column_transformer |
93 | 94 |
|
94 |
| -preprocessor = ColumnTransformer( |
95 |
| - [ |
96 |
| - ("one-hot-encoder", categorical_preprocessor, categorical_columns), |
97 |
| - ("standard_scaler", numerical_preprocessor, numerical_columns), |
98 |
| - ] |
| 95 | +preprocessor = make_column_transformer( |
| 96 | + (categorical_preprocessor, categorical_columns), |
| 97 | + (numerical_preprocessor, numerical_columns), |
99 | 98 | )
|
100 | 99 |
|
101 | 100 | # %% [markdown]
|
|
234 | 233 | handle_unknown="use_encoded_value", unknown_value=-1
|
235 | 234 | )
|
236 | 235 |
|
237 |
| -preprocessor = ColumnTransformer( |
238 |
| - [("categorical", categorical_preprocessor, categorical_columns)], |
| 236 | +preprocessor = make_column_transformer( |
| 237 | + (categorical_preprocessor, categorical_columns), |
239 | 238 | remainder="passthrough",
|
240 | 239 | )
|
241 | 240 |
|
|
0 commit comments