cblearn.preprocessing.MultiColumnLabelEncoder#
- class cblearn.preprocessing.MultiColumnLabelEncoder[source]#
Encoder for objects that are a combination of labels in multiple columns.
Extends the function of scikit-learn’s label encoder to 2d arrays. See
sklearn.preprocessing.LabelEncoderfor more information.>>> encoder = MultiColumnLabelEncoder() >>> label_data = [[0.1, 'high'], [0.3, 'low'], [0.1, 'high'], [0.1, 'low']] >>> encoder.fit(label_data).transform(label_data).tolist() [0, 2, 0, 1] >>> encoder.fit_transform(label_data).tolist() [0, 2, 0, 1] >>> encoder.inverse_transform([2, 1, 0]).tolist() [['0.3', 'low'], ['0.1', 'low'], ['0.1', 'high']]
- __init__()#
Methods
__init__()fit(X[, y])Fit label encoder.
fit_transform(X[, y])Fit label encoder and return encoded labels.
Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
inverse_transform(X[, y])Transform labels back to original encoding.
set_output(*[, transform])Set output container.
set_params(**params)Set the parameters of this estimator.
transform(X[, y])Transform labels to normalized encoding.
- fit(X, y=None)[source]#
Fit label encoder.
- Parameters:
y (array-like of shape (n_samples,)) – Target values.
- Returns:
self – Fitted label encoder.
- Return type:
returns an instance of self.
- fit_transform(X, y=None)[source]#
Fit label encoder and return encoded labels.
- Parameters:
y (array-like of shape (n_samples,)) – Target values.
- Returns:
y – Encoded labels.
- Return type:
array-like of shape (n_samples,)
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequestencapsulating routing information.- Return type:
MetadataRequest
- get_params(deep=True)#
Get parameters for this estimator.
- inverse_transform(X, y=None)[source]#
Transform labels back to original encoding.
- Parameters:
y (ndarray of shape (n_samples,)) – Target values.
- Returns:
y – Original encoding.
- Return type:
ndarray of shape (n_samples,)
- set_output(*, transform=None)#
Set output container.
See sphx_glr_auto_examples_miscellaneous_plot_set_output.py for an example on how to use the API.
- Parameters:
transform ({"default", "pandas", "polars"}, default=None) –
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
Added in version 1.4: “polars” option was added.
- Returns:
self – Estimator instance.
- Return type:
estimator instance
- set_params(**params)#
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
**params (dict) – Estimator parameters.
- Returns:
self – Estimator instance.
- Return type:
estimator instance