skactiveml.utils.ExtLabelEncoder#

class skactiveml.utils.ExtLabelEncoder(classes=None, missing_label=nan)[source]#

Bases: BaseEstimator

Encode class labels with value between 0 and classes-1 and uses -1 for unlabeled samples. This transformer should be used to encode class labels, i.e. y, and not the input X.

Parameters
classesarray-like of shape (n_classes,), default=None

Holds the label for each class.

missing_labelscalar or string or np.nan or None, default=np.nan

Value to represent a missing label.

Attributes
classes_np.ndarray of shape (n_classes,)

Holds the label for each class.

Methods

fit(y)

Fit label encoder.

fit_transform(y)

Fit label encoder and return encoded labels.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

inverse_transform(y)

Transform labels back to original encoding.

set_params(**params)

Set the parameters of this estimator.

transform(y)

Transform labels to new class encoding.

fit(y)[source]#

Fit label encoder.

Parameters
yarray-like of shape (n_samples,) or (n_samples, n_outputs)

Class labels.

Returns
selfExtLabelEncoder

Returns an instance of ExtLabelEncoder.

fit_transform(y)[source]#

Fit label encoder and return encoded labels.

Parameters
yarray-like of shape (n_samples,) or (n_samples, n_outputs)

Class labels.

Returns
ynp.ndarray shape (n_samples,) or (n_samples, n_outputs)

Class labels.

get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)#

Get parameters for this estimator.

Parameters
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns
paramsdict

Parameter names mapped to their values.

inverse_transform(y)[source]#

Transform labels back to original encoding.

Parameters
ynumpy array of shape (n_samples,) or (n_samples, n_outputs)

Encoded class labels.

Returns
y_decnp.ndarray of shape (n_samples,) or (n_samples, n_outputs)

Decoded (original) class labels.

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
**paramsdict

Estimator parameters.

Returns
selfestimator instance

Estimator instance.

transform(y)[source]#

Transform labels to new class encoding.

Parameters
yarray-like of shape (n_samples,) or (n_samples, n_outputs)

Original class labels.

Returns
y_encarray-like of shape (n_samples) or (n_samples, n_outputs)

Encoded class labels.