ExtLabelEncoder#
- class skactiveml.utils.ExtLabelEncoder(classes=None, missing_label=nan, target_type='single-output')[source]#
Bases:
BaseEstimatorEncode class labels with integers in [0, …, n_classes-1] and use -1 for unlabeled.
- Parameters:
- classesarray-like of shape (n_classes,) or a list of such array-likes, default=None
If classes is not nested (None or one-dimensional), a single task problem is assumed such that y can be shape (n_samples,) or (n_samples, n_annotators). Same encoder is applied to all entries.
If classes is nested, target_type must be “multi-label”, and y must contain one column per binary class vocabulary.
- missing_labelscalar or string or np.nan or None, default=np.nan
Value to represent a missing label.
- target_type“single-output” or “multi-label”, default=”single-output”
Resolved target type controlling whether one shared encoder or one encoder per label is used.
Methods
fit(y)Fit label encoder.
Fit label encoder and return encoded labels.
Transform labels back to original encoding.
transform(y)Transform labels to new class encoding.
Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
set_params(**params)Set the parameters of this estimator.
- ExtLabelEncoder.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.
- 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.
- ExtLabelEncoder.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.
- ExtLabelEncoder.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.
- ExtLabelEncoder.get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- ExtLabelEncoder.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.
- ExtLabelEncoder.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.