sklearn.pipeline.FeatureUnion¶
- class sklearn.pipeline.FeatureUnion(transformer_list, n_jobs=1, transformer_weights=None)[source]¶
Concatenates results of multiple transformer objects.
This estimator applies a list of transformer objects in parallel to the input data, then concatenates the results. This is useful to combine several feature extraction mechanisms into a single transformer.
Parameters: transformer_list: list of (string, transformer) tuples :
List of transformer objects to be applied to the data. The first half of each tuple is the name of the transformer.
n_jobs: int, optional :
Number of jobs to run in parallel (default 1).
transformer_weights: dict, optional :
Multiplicative weights for features per transformer. Keys are transformer names, values the weights.
Methods
fit(X[, y]) Fit all transformers using X. fit_transform(X[, y]) Fit all transformers using X, transform the data and concatenate results. get_feature_names() Get feature names from all transformers. get_params([deep]) set_params(**params) Set the parameters of this estimator. transform(X) Transform X separately by each transformer, concatenate results. - fit(X, y=None)[source]¶
Fit all transformers using X.
Parameters: X : array-like or sparse matrix, shape (n_samples, n_features)
Input data, used to fit transformers.
- fit_transform(X, y=None, **fit_params)[source]¶
Fit all transformers using X, transform the data and concatenate results.
Parameters: X : array-like or sparse matrix, shape (n_samples, n_features)
Input data to be transformed.
Returns: X_t : array-like or sparse matrix, shape (n_samples, sum_n_components)
hstack of results of transformers. sum_n_components is the sum of n_components (output dimension) over transformers.
- get_feature_names()[source]¶
Get feature names from all transformers.
Returns: feature_names : list of strings
Names of the features produced by transform.
- set_params(**params)[source]¶
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The former have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
Returns: self :
- transform(X)[source]¶
Transform X separately by each transformer, concatenate results.
Parameters: X : array-like or sparse matrix, shape (n_samples, n_features)
Input data to be transformed.
Returns: X_t : array-like or sparse matrix, shape (n_samples, sum_n_components)
hstack of results of transformers. sum_n_components is the sum of n_components (output dimension) over transformers.