Fit label encoder and return encoded labels. Parameters ---------- y : array-like of shape (n_samples,) Target values. Returns ------- y : array-like of shape (n_samples,) Encoded labels.
(self, y)
| 105 | return self |
| 106 | |
| 107 | def fit_transform(self, y): |
| 108 | """Fit label encoder and return encoded labels. |
| 109 | |
| 110 | Parameters |
| 111 | ---------- |
| 112 | y : array-like of shape (n_samples,) |
| 113 | Target values. |
| 114 | |
| 115 | Returns |
| 116 | ------- |
| 117 | y : array-like of shape (n_samples,) |
| 118 | Encoded labels. |
| 119 | """ |
| 120 | y = column_or_1d(y, warn=True) |
| 121 | self.classes_, y = _unique(y, return_inverse=True) |
| 122 | return y |
| 123 | |
| 124 | def transform(self, y): |
| 125 | """Transform labels to normalized encoding. |