LabelEncoder
¶
-
class
ibex.sklearn.preprocessing.
LabelEncoder
¶ Bases:
sklearn.preprocessing.label.LabelEncoder
,ibex._base.FrameMixin
Note
The documentation following is of the class wrapped by this class. There are some changes, in particular:
- A parameter
X
denotes apandas.DataFrame
. - A parameter
y
denotes apandas.Series
.
Encode labels with value between 0 and n_classes-1.
Read more in the User Guide.
- classes_ : array of shape (n_class,)
- Holds the label for each class.
LabelEncoder can be used to normalize labels.
>>> from sklearn import preprocessing >>> le = preprocessing.LabelEncoder() >>> le.fit([1, 2, 2, 6]) LabelEncoder() >>> le.classes_ array([1, 2, 6]) >>> le.transform([1, 1, 2, 6]) array([0, 0, 1, 2]...) >>> le.inverse_transform([0, 0, 1, 2]) array([1, 1, 2, 6])
It can also be used to transform non-numerical labels (as long as they are hashable and comparable) to numerical labels.
>>> le = preprocessing.LabelEncoder() >>> le.fit(["paris", "paris", "tokyo", "amsterdam"]) LabelEncoder() >>> list(le.classes_) ['amsterdam', 'paris', 'tokyo'] >>> le.transform(["tokyo", "tokyo", "paris"]) array([2, 2, 1]...) >>> list(le.inverse_transform([2, 2, 1])) ['tokyo', 'tokyo', 'paris']
- sklearn.preprocessing.OneHotEncoder : encode categorical integer features
- using a one-hot aka one-of-K scheme.
-
fit
(y)[source]¶ Note
The documentation following is of the class wrapped by this class. There are some changes, in particular:
- A parameter
X
denotes apandas.DataFrame
. - A parameter
y
denotes apandas.Series
.
Fit label encoder
- y : array-like of shape (n_samples,)
- Target values.
self : returns an instance of self.
- A parameter
-
fit_transform
(y)[source]¶ Note
The documentation following is of the class wrapped by this class. There are some changes, in particular:
- A parameter
X
denotes apandas.DataFrame
. - A parameter
y
denotes apandas.Series
.
Fit label encoder and return encoded labels
- y : array-like of shape [n_samples]
- Target values.
y : array-like of shape [n_samples]
- A parameter
-
inverse_transform
(y)[source]¶ Note
The documentation following is of the class wrapped by this class. There are some changes, in particular:
- A parameter
X
denotes apandas.DataFrame
. - A parameter
y
denotes apandas.Series
.
Transform labels back to original encoding.
- y : numpy array of shape [n_samples]
- Target values.
y : numpy array of shape [n_samples]
- A parameter
-
transform
(y)[source]¶ Note
The documentation following is of the class wrapped by this class. There are some changes, in particular:
- A parameter
X
denotes apandas.DataFrame
. - A parameter
y
denotes apandas.Series
.
Transform labels to normalized encoding.
- y : array-like of shape [n_samples]
- Target values.
y : array-like of shape [n_samples]
- A parameter
- A parameter