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

Class LabelBinarizer

sklearn/preprocessing/_label.py:184–462  ·  view source on GitHub ↗

Binarize labels in a one-vs-all fashion. Several regression and binary classification algorithms are available in scikit-learn. A simple way to extend these algorithms to the multi-class classification case is to use the so-called one-vs-all scheme. At learning time, this simpl

Source from the content-addressed store, hash-verified

182
183
184class LabelBinarizer(TransformerMixin, BaseEstimator, auto_wrap_output_keys=None):
185 """Binarize labels in a one-vs-all fashion.
186
187 Several regression and binary classification algorithms are
188 available in scikit-learn. A simple way to extend these algorithms
189 to the multi-class classification case is to use the so-called
190 one-vs-all scheme.
191
192 At learning time, this simply consists in learning one regressor
193 or binary classifier per class. In doing so, one needs to convert
194 multi-class labels to binary labels (belong or does not belong
195 to the class). `LabelBinarizer` makes this process easy with the
196 transform method.
197
198 At prediction time, one assigns the class for which the corresponding
199 model gave the greatest confidence. `LabelBinarizer` makes this easy
200 with the :meth:`inverse_transform` method.
201
202 Read more in the :ref:`User Guide <preprocessing_targets>`.
203
204 Parameters
205 ----------
206 neg_label : int, default=0
207 Value with which negative labels must be encoded.
208
209 pos_label : int, default=1
210 Value with which positive labels must be encoded.
211
212 sparse_output : bool, default=False
213 True if the returned array from transform is desired to be in sparse
214 CSR format.
215
216 Attributes
217 ----------
218 classes_ : ndarray of shape (n_classes,)
219 Holds the label for each class.
220
221 y_type_ : str
222 Represents the type of the target data as evaluated by
223 :func:`~sklearn.utils.multiclass.type_of_target`. Possible type are
224 'continuous', 'continuous-multioutput', 'binary', 'multiclass',
225 'multiclass-multioutput', 'multilabel-indicator', and 'unknown'.
226
227 sparse_input_ : bool
228 `True` if the input data to transform is given as a sparse matrix,
229 `False` otherwise.
230
231 See Also
232 --------
233 label_binarize : Function to perform the transform operation of
234 LabelBinarizer with fixed classes.
235 OneHotEncoder : Encode categorical features using a one-hot aka one-of-K
236 scheme.
237
238 Examples
239 --------
240 >>> from sklearn.preprocessing import LabelBinarizer
241 >>> lb = LabelBinarizer()

Callers 15

fitMethod · 0.90
partial_fitMethod · 0.90
fitMethod · 0.90
_validate_inputMethod · 0.90
partial_fitMethod · 0.90
test_gradientFunction · 0.90
chi2Function · 0.90
_fit_encodings_allMethod · 0.90
test_encoding_multiclassFunction · 0.90
test_label_binarizerFunction · 0.90

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…