MCPcopy Index your code
hub / github.com/scikit-learn/scikit-learn / transform

Method transform

sklearn/preprocessing/_label.py:124–144  ·  view source on GitHub ↗

Transform labels to normalized encoding. Parameters ---------- y : array-like of shape (n_samples,) Target values. Returns ------- y : array-like of shape (n_samples,) Labels as normalized encodings.

(self, y)

Source from the content-addressed store, hash-verified

122 return y
123
124 def transform(self, y):
125 """Transform labels to normalized encoding.
126
127 Parameters
128 ----------
129 y : array-like of shape (n_samples,)
130 Target values.
131
132 Returns
133 -------
134 y : array-like of shape (n_samples,)
135 Labels as normalized encodings.
136 """
137 check_is_fitted(self)
138 xp, _ = get_namespace(y)
139 y = column_or_1d(y, dtype=self.classes_.dtype, warn=True)
140 # transform of empty array is empty array
141 if _num_samples(y) == 0:
142 return xp.asarray([])
143
144 return _encode(y, uniques=self.classes_)
145
146 def inverse_transform(self, y):
147 """Transform labels back to original encoding.

Callers 14

compute_class_weightFunction · 0.95
test_label_encoderFunction · 0.95
test_nan_label_encoderFunction · 0.95
matthews_corrcoefFunction · 0.95
hinge_lossFunction · 0.95
from_estimatorMethod · 0.95

Calls 5

check_is_fittedFunction · 0.90
get_namespaceFunction · 0.90
column_or_1dFunction · 0.90
_num_samplesFunction · 0.90
_encodeFunction · 0.90