# label_binarize

### cuml.preprocessing.label_binarize(y, classes, neg_label=0, pos_label=1, sparse_output=False)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/preprocessing/label.py#L199)

Binarize labels in a one-vs-all fashion.

* **Parameters:**
  **y**
  : Target values. The 2-d matrix should only contain 0 and 1, in the
    multilabel-indicator format.

  **classes**
  : The class labels for each class.

  **neg_label**
  : The value to use for encoding negative labels.

  **pos_label**
  : The value to use for encoding positive labels.

  **sparse_output**
  : If true, a sparse CSR matrix is returned.
* **Returns:**
  **y**
  : The encoded labels. Will be a sparse matrix if `sparse_output=True`.
    Shape will be (n_samples, n_classes) for multiclass problems,
    (n_samples, 1) for binary problems with no unseen classes, and
    (n_samples, 2) for binary problems with unseen classes (a minor,
    intentional deviation from sklearn).

#### SEE ALSO
[`LabelBinarizer`](../cuml.preprocessing.LabelBinarizer/index.html.md#cuml.preprocessing.LabelBinarizer)
: A class version of this function.

### Examples

```pycon
>>> from cuml.preprocessing import label_binarize
>>> label_binarize([1, 6], classes=[1, 2, 4, 6])
array([[1, 0, 0, 0],
       [0, 0, 0, 1]], dtype=int32)
```

Binary targets result in a column vector:

```pycon
>>> label_binarize(['a', 'b', 'b', 'a'], classes=['a', 'b'])
array([[0],
       [1],
       [1],
       [0]], dtype=int32)
```

<!-- !! processed by numpydoc !! -->
