glassbox.cleaner.encoders¶
OneHotEncoder and LabelEncoder for categorical feature encoding.
OneHotEncoder
¶
Bases: BaseTransformer
Encode categorical features as a one-hot numeric array.
Source code in glassbox/cleaner/encoders.py
fit
¶
Learn the categorical levels for encoding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Input array of shape (n_samples, n_features). |
required |
Returns:
| Type | Description |
|---|---|
Self
|
Fitted encoder instance. |
Source code in glassbox/cleaner/encoders.py
transform
¶
Transform the dataset into a one-hot encoded representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Input array of shape (n_samples, n_features). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Transformed array properly encoded. |
Source code in glassbox/cleaner/encoders.py
LabelEncoder
¶
Bases: BaseTransformer
Encode target labels with value between 0 and n_classes-1.
Source code in glassbox/cleaner/encoders.py
fit
¶
Learn the vocabulary of the labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Input array of shape (n_samples, n_features). |
required |
Returns:
| Type | Description |
|---|---|
Self
|
Fitted encoder instance. |
Source code in glassbox/cleaner/encoders.py
transform
¶
Transform labels to normalized encoding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Input array of shape (n_samples, n_features). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Transformed array properly encoded. |