Skip to content

Commit 955ec74

Browse files
authored
DOC add example with set_params. (scikit-learn#29243)
1 parent bd8f5bd commit 955ec74

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

examples/miscellaneous/plot_set_output.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@
6363
# means that the final logistic regression step contains the feature names of the input.
6464
clf[-1].feature_names_in_
6565

66+
# %%
67+
# .. note:: If one uses the method `set_params`, the transformer will be
68+
# replaced by a new one with the default output format.
69+
clf.set_params(standardscaler=StandardScaler())
70+
clf.fit(X_train, y_train)
71+
clf[-1].feature_names_in_
72+
73+
# %%
74+
# To keep the intended behavior, use `set_output` on the new transformer
75+
# beforehand
76+
scaler = StandardScaler().set_output(transform="pandas")
77+
clf.set_params(standardscaler=scaler)
78+
clf.fit(X_train, y_train)
79+
clf[-1].feature_names_in_
80+
6681
# %%
6782
# Next we load the titanic dataset to demonstrate `set_output` with
6883
# :class:`compose.ColumnTransformer` and heterogeneous data.

0 commit comments

Comments
 (0)