skbel.preprocessing
This package contains classes for preprocessing data.
skbel.preprocessing.composite
- class skbel.preprocessing.composite.CompositePCA(n_components: list, scale: bool = False)[source]
Bases:
TransformerMixin,BaseEstimator- __init__(n_components: list, scale: bool = False)[source]
Initiate the class by specifying a list of number of components to keep for each different datasets.
- Parameters:
n_components – list of number of components to keep for each dataset
scale – whether to scale the data before applying PCA
- _sklearn_auto_wrap_output_keys = {'transform'}
- fit(Xc: list, yc=None, **fit_params)[source]
Fit all PCA objects for the different datasets with their specified n_components.
- Parameters:
Xc – list of datasets
yc – Only here to satisfy the scikit-learn API
- Returns:
self
- fit_transform(Xc: list, yc=None, **fit_params)[source]
Fit and transform all datasets.
- Parameters:
Xc – list of datasets
yc – Only here to satisfy the scikit-learn API
- Returns:
concatenated output
- inverse_transform(Xr: array, yc=None, **fit_params) list[source]
Inverse transform the data back to the original space.
- Parameters:
Xr – transformed data
yc – Only here to satisfy the scikit-learn API
- Returns:
list of transformed datasets
- set_fit_request(*, Xc: bool | None | str = '$UNCHANGED$', yc: bool | None | str = '$UNCHANGED$') CompositePCA
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Parameters
- Xcstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
Xcparameter infit.- ycstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
ycparameter infit.
Returns
- selfobject
The updated object.
- set_inverse_transform_request(*, Xr: bool | None | str = '$UNCHANGED$', yc: bool | None | str = '$UNCHANGED$') CompositePCA
Configure whether metadata should be requested to be passed to the
inverse_transformmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toinverse_transformif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toinverse_transform.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Parameters
- Xrstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
Xrparameter ininverse_transform.- ycstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
ycparameter ininverse_transform.
Returns
- selfobject
The updated object.
- set_transform_request(*, Xc: bool | None | str = '$UNCHANGED$', yc: bool | None | str = '$UNCHANGED$') CompositePCA
Configure whether metadata should be requested to be passed to the
transformmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed totransformif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it totransform.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Parameters
- Xcstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
Xcparameter intransform.- ycstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
ycparameter intransform.
Returns
- selfobject
The updated object.
- class skbel.preprocessing.composite.CompositeTransformer(base_function, **fit_params)[source]
Bases:
TransformerMixin,BaseEstimator- __init__(base_function, **fit_params)[source]
Initiate the class by specifying a base scikit-learn object and the parameters to use for each dataset.
- Parameters:
base_function – function to apply to the data
fit_params – parameters to pass to the base function
- _sklearn_auto_wrap_output_keys = {'transform'}
- fit(Xc: list, yc=None, **fit_params)[source]
Fit all transformations for the different datasets with their specified parameters.
- Parameters:
Xc – list of datasets
yc – Only here to satisfy the scikit-learn API
- Returns:
self
- fit_transform(Xc: list, yc=None, **fit_params)[source]
Fit and transform all datasets.
- Parameters:
Xc – list of datasets
yc – Only here to satisfy the scikit-learn API
- Returns:
concatenated output
- inverse_transform(Xr: array, yc=None, **fit_params) list[source]
Inverse transform the data back to the original space.
- Parameters:
Xr – transformed data
yc – Only here to satisfy the scikit-learn API
- Returns:
list of transformed datasets
- set_fit_request(*, Xc: bool | None | str = '$UNCHANGED$', yc: bool | None | str = '$UNCHANGED$') CompositeTransformer
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Parameters
- Xcstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
Xcparameter infit.- ycstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
ycparameter infit.
Returns
- selfobject
The updated object.
- set_inverse_transform_request(*, Xr: bool | None | str = '$UNCHANGED$', yc: bool | None | str = '$UNCHANGED$') CompositeTransformer
Configure whether metadata should be requested to be passed to the
inverse_transformmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toinverse_transformif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toinverse_transform.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Parameters
- Xrstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
Xrparameter ininverse_transform.- ycstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
ycparameter ininverse_transform.
Returns
- selfobject
The updated object.
- set_transform_request(*, Xc: bool | None | str = '$UNCHANGED$', yc: bool | None | str = '$UNCHANGED$') CompositeTransformer
Configure whether metadata should be requested to be passed to the
transformmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed totransformif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it totransform.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Parameters
- Xcstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
Xcparameter intransform.- ycstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
ycparameter intransform.
Returns
- selfobject
The updated object.
- class skbel.preprocessing.composite.Dummy[source]
Bases:
TransformerMixin,MultiOutputMixin,BaseEstimatorDummy transformer that does nothing.
- _sklearn_auto_wrap_output_keys = {'transform'}
- fit_transform(X=None, y=None, **fit_params)[source]
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Parameters
- Xarray-like of shape (n_samples, n_features)
Input samples.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None
Target values (None for unsupervised transformations).
- **fit_paramsdict
Additional fit parameters. Pass only if the estimator accepts additional params in its fit method.
Returns
- X_newndarray array of shape (n_samples, n_features_new)
Transformed array.
skbel.preprocessing.dct
Discrete Cosine Transform written in scikit-learn style.
- class skbel.preprocessing.dct.DiscreteCosineTransform2D(*, m_cut: int = None, n_cut: int = None)[source]
Bases:
TransformerMixin,BaseEstimator- _sklearn_auto_wrap_output_keys = {'transform'}
- fit_transform(X, y=None, **fit_params)[source]
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Parameters
- Xarray-like of shape (n_samples, n_features)
Input samples.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None
Target values (None for unsupervised transformations).
- **fit_paramsdict
Additional fit parameters. Pass only if the estimator accepts additional params in its fit method.
Returns
- X_newndarray array of shape (n_samples, n_features_new)
Transformed array.