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
- classes: array-like, shape (n_classes), default=None
Holds the label for each class.
- missing_label: scalar|string|np.nan|None, default=np.nan
Value to represent a missing label.
- Attributes
- classes_: array-like, shape (n_classes)
Holds the label for each class.
Methods
fit
(y)Fit label encoder.
Fit label encoder and return encoded labels.
Get metadata routing of this object.
get_params
([deep])Get parameters for this estimator.
Transform labels back to original encoding.
set_params
(**params)Set the parameters of this estimator.
transform
(y)Transform labels to normalized encoding.
- fit(y)[source]#
Fit label encoder.
- Parameters
- y: array-like, shape (n_samples) or (n_samples, n_outputs)
Class labels.
- Returns
- self: returns an instance of self.
- fit_transform(y)[source]#
Fit label encoder and return encoded labels.
- Parameters
- y: array-like, shape (n_samples) or (n_samples, n_outputs)
Class labels.
- Returns
- y: array-like, 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]
Target values.
- Returns
- y_decnumpy array of shape [n_samples]
- 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.