|
82 | 82 | "\n", |
83 | 83 | "from sklearn.model_selection import cross_validate\n", |
84 | 84 | "from sklearn.pipeline import make_pipeline\n", |
85 | | - "from sklearn.compose import ColumnTransformer\n", |
| 85 | + "from sklearn.compose import make_column_transformer\n", |
86 | 86 | "from sklearn.preprocessing import OrdinalEncoder\n", |
87 | 87 | "from sklearn.ensemble import HistGradientBoostingClassifier\n", |
88 | 88 | "\n", |
89 | 89 | "categorical_preprocessor = OrdinalEncoder(\n", |
90 | 90 | " handle_unknown=\"use_encoded_value\", unknown_value=-1\n", |
91 | 91 | ")\n", |
92 | | - "preprocessor = ColumnTransformer(\n", |
93 | | - " [(\"categorical\", categorical_preprocessor, categorical_columns)],\n", |
| 92 | + "preprocessor = make_column_transformer(\n", |
| 93 | + " (categorical_preprocessor, categorical_columns),\n", |
94 | 94 | " remainder=\"passthrough\",\n", |
95 | 95 | ")\n", |
96 | 96 | "\n", |
| 97 | + "\n", |
97 | 98 | "model = make_pipeline(preprocessor, HistGradientBoostingClassifier())\n", |
98 | 99 | "\n", |
99 | 100 | "start = time.time()\n", |
|
130 | 131 | "\n", |
131 | 132 | "from sklearn.preprocessing import StandardScaler\n", |
132 | 133 | "\n", |
133 | | - "preprocessor = ColumnTransformer(\n", |
134 | | - " [\n", |
135 | | - " (\"numerical\", StandardScaler(), numerical_columns),\n", |
136 | | - " (\n", |
137 | | - " \"categorical\",\n", |
138 | | - " OrdinalEncoder(\n", |
139 | | - " handle_unknown=\"use_encoded_value\", unknown_value=-1\n", |
140 | | - " ),\n", |
141 | | - " categorical_columns,\n", |
142 | | - " ),\n", |
143 | | - " ]\n", |
| 134 | + "preprocessor = make_column_transformer(\n", |
| 135 | + " (StandardScaler(), numerical_columns),\n", |
| 136 | + " (\n", |
| 137 | + " OrdinalEncoder(handle_unknown=\"use_encoded_value\", unknown_value=-1),\n", |
| 138 | + " categorical_columns,\n", |
| 139 | + " ),\n", |
144 | 140 | ")\n", |
145 | 141 | "\n", |
146 | 142 | "model = make_pipeline(preprocessor, HistGradientBoostingClassifier())\n", |
|
209 | 205 | "categorical_preprocessor = OneHotEncoder(\n", |
210 | 206 | " handle_unknown=\"ignore\", sparse_output=False\n", |
211 | 207 | ")\n", |
212 | | - "preprocessor = ColumnTransformer(\n", |
213 | | - " [(\"one-hot-encoder\", categorical_preprocessor, categorical_columns)],\n", |
| 208 | + "preprocessor = make_column_transformer(\n", |
| 209 | + " (categorical_preprocessor, categorical_columns),\n", |
214 | 210 | " remainder=\"passthrough\",\n", |
215 | 211 | ")\n", |
216 | 212 | "\n", |
|
0 commit comments