Background
sklearn.compose.make_column_transformer is the standard way to apply different preprocessing to different column subsets - useful when only some X columns need centring/scaling, or when you mix MCUVScaler with OneHotEncoder on categorical features inside a Pipeline:
from sklearn.compose import make_column_transformer
from sklearn.preprocessing import OneHotEncoder
from process_improve.multivariate import MCUVScaler, PLS
ct = make_column_transformer(
(MCUVScaler(), ["temp", "pressure", "flow"]),
(OneHotEncoder(), ["batch_type"]),
remainder="drop",
)
pipe = Pipeline([("ct", ct), ("pls", PLS(n_components=3))])
The sklearn Pipeline interop audit in #383 never tried this. Probable issues:
MCUVScaler may return a pd.DataFrame while OneHotEncoder returns a sparse matrix; ColumnTransformer needs to concatenate them.
- The output of
make_column_transformer is an ndarray (or sparse matrix) when mixing types - PLS.fit may need to handle that.
get_feature_names_out (see the separate issue) becomes important here for downstream introspection.
What to do
- Add a focused test that walks the example above end-to-end.
- Fix anything that surfaces.
- Document the pattern in the README if it works cleanly.
Related
Spun out from the sklearn interop audit attached to #383. Likely benefits from / requires the get_feature_names_out fix from the related issue.
Background
sklearn.compose.make_column_transformeris the standard way to apply different preprocessing to different column subsets - useful when only some X columns need centring/scaling, or when you mixMCUVScalerwithOneHotEncoderon categorical features inside a Pipeline:The sklearn Pipeline interop audit in #383 never tried this. Probable issues:
MCUVScalermay return apd.DataFramewhileOneHotEncoderreturns a sparse matrix;ColumnTransformerneeds to concatenate them.make_column_transformeris an ndarray (or sparse matrix) when mixing types -PLS.fitmay need to handle that.get_feature_names_out(see the separate issue) becomes important here for downstream introspection.What to do
Related
Spun out from the sklearn interop audit attached to #383. Likely benefits from / requires the
get_feature_names_outfix from the related issue.