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 of the transformers may be set using its name and the parameter name separated by a ‘__’. A transformer may be replaced entirely by setting the parameter with its name to another transformer, removed by setting to ‘drop’ or disabled by setting to ‘passthrough’ (features are passed without transformation).
Read more in the User Guide.
Added in version 0.13.
List of transformer objects to be applied to the data. The first half of each tuple is the name of the transformer. The transformer can be ‘drop’ for it to be ignored or can be ‘passthrough’ for features to be passed unchanged.
Added in version 1.1: Added the option "passthrough"
.
Changed in version 0.22: Deprecated None
as a transformer in favor of ‘drop’.
Number of jobs to run in parallel. None
means 1 unless in a joblib.parallel_backend
context. -1
means using all processors. See Glossary for more details.
Changed in version v0.20: n_jobs
default changed from 1 to None
Multiplicative weights for features per transformer. Keys are transformer names, values the weights. Raises ValueError if key not present in transformer_list
.
If True, the time elapsed while fitting each transformer will be printed as it is completed.
If True, get_feature_names_out
will prefix all feature names with the name of the transformer that generated that feature. If False, get_feature_names_out
will not prefix any feature names and will error if feature names are not unique.
Added in version 1.5.
Bunch
Dictionary-like object, with the following attributes. Read-only attribute to access any transformer parameter by user given name. Keys are transformer names and values are transformer parameters.
Added in version 1.2.
n_features_in_
int
Number of features seen during fit.
feature_names_in_
ndarray of shape (n_features_in_
,)
Names of features seen during fit.
See also
make_union
Convenience function for simplified feature union construction.
Examples
>>> from sklearn.pipeline import FeatureUnion >>> from sklearn.decomposition import PCA, TruncatedSVD >>> union = FeatureUnion([("pca", PCA(n_components=1)), ... ("svd", TruncatedSVD(n_components=2))]) >>> X = [[0., 1., 3], [2., 2., 5]] >>> union.fit_transform(X) array([[-1.5 , 3.04, -0.872], [ 1.5 , 5.72, 0.463]]) >>> # An estimator's parameter can be set using '__' syntax >>> union.set_params(svd__n_components=1).fit_transform(X) array([[-1.5 , 3.04], [ 1.5 , 5.72]])
For a more detailed example of usage, see Concatenating multiple feature extraction methods.
Fit all transformers using X.
Input data, used to fit transformers.
Targets for supervised learning.
If enable_metadata_routing=False
(default): Parameters directly passed to the fit
methods of the sub-transformers.
If enable_metadata_routing=True
: Parameters safely routed to the fit
methods of the sub-transformers. See Metadata Routing User Guide for more details.
Changed in version 1.5: **fit_params
can be routed via metadata routing API.
FeatureUnion class instance.
Fit all transformers, transform the data and concatenate results.
Input data to be transformed.
Targets for supervised learning.
If enable_metadata_routing=False
(default): Parameters directly passed to the fit
methods of the sub-transformers.
If enable_metadata_routing=True
: Parameters safely routed to the fit
methods of the sub-transformers. See Metadata Routing User Guide for more details.
Changed in version 1.5: **params
can now be routed via metadata routing API.
The hstack
of results of transformers. sum_n_components
is the sum of n_components
(output dimension) over transformers.
Get output feature names for transformation.
Input features.
Transformed feature names.
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Added in version 1.5.
A MetadataRouter
encapsulating routing information.
Get parameters for this estimator.
Returns the parameters given in the constructor as well as the estimators contained within the transformer_list
of the FeatureUnion
.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Set the output container when "transform"
and "fit_transform"
are called.
set_output
will set the output of all estimators in transformer_list
.
Configure output of transform
and fit_transform
.
"default"
: Default output format of a transformer
"pandas"
: DataFrame output
"polars"
: Polars output
None
: Transform configuration is unchanged
Estimator instance.
Set the parameters of this estimator.
Valid parameter keys can be listed with get_params()
. Note that you can directly set the parameters of the estimators contained in transformer_list
.
Parameters of this estimator or parameters of estimators contained in transform_list
. Parameters of the transformers may be set using its name and the parameter name separated by a ‘__’.
FeatureUnion class instance.
Transform X separately by each transformer, concatenate results.
Input data to be transformed.
Parameters routed to the transform
method of the sub-transformers via the metadata routing API. See Metadata Routing User Guide for more details.
Added in version 1.5.
The hstack
of results of transformers. sum_n_components
is the sum of n_components
(output dimension) over transformers.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4