Skip to content

Verify make_column_transformer with MCUVScaler + PLS Pipeline #399

Description

@kgdunn

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

  1. Add a focused test that walks the example above end-to-end.
  2. Fix anything that surfaces.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions