sklearn.compose
.make_column_transformer¶
-
sklearn.compose.
make_column_transformer
(*transformers, **kwargs)[source]¶ Construct a ColumnTransformer from the given transformers.
This is a shorthand for the ColumnTransformer constructor; it does not require, and does not permit, naming the transformers. Instead, they will be given names automatically based on their types. It also does not allow weighting.
Parameters: - *transformers : tuples of column selections and transformers
- remainder : {‘passthrough’, ‘drop’} or estimator, default ‘passthrough’
By default, all remaining columns that were not specified in transformers will be automatically passed through (default of
'passthrough'
). This subset of columns is concatenated with the output of the transformers. By usingremainder='drop'
, only the specified columns in transformers are transformed and combined in the output, and the non-specified columns are dropped. By settingremainder
to be an estimator, the remaining non-specified columns will use theremainder
estimator. The estimator must support fit and transform.- n_jobs : int, optional
Number of jobs to run in parallel (default 1).
Returns: - ct : ColumnTransformer
See also
sklearn.compose.ColumnTransformer
- Class that allows combining the outputs of multiple transformer objects used on column subsets of the data into a single feature space.
Examples
>>> from sklearn.preprocessing import StandardScaler, OneHotEncoder >>> from sklearn.compose import make_column_transformer >>> make_column_transformer( ... (['numerical_column'], StandardScaler()), ... (['categorical_column'], OneHotEncoder())) ... ColumnTransformer(n_jobs=1, remainder='passthrough', transformer_weights=None, transformers=[('standardscaler', StandardScaler(...), ['numerical_column']), ('onehotencoder', OneHotEncoder(...), ['categorical_column'])])