# LabelBinarizer

### *class* cuml.dask.preprocessing.LabelBinarizer(, client=None, \*\*kwargs)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/preprocessing/label.py#L11)

A distributed version of LabelBinarizer for one-hot encoding
a collection of labels.

* **Parameters:**
  **client**
  : Dask client to use

  **\*\*kwargs**
  : Additional arguments passed to the underlying single-GPU LabelBinarizer

### Methods

| [`fit`](#cuml.dask.preprocessing.LabelBinarizer.fit)(y)                            | Fit label binarizer                                    |
|------------------------------------------------------------------------------------|--------------------------------------------------------|
| [`fit_transform`](#cuml.dask.preprocessing.LabelBinarizer.fit_transform)(y)                  | Fit the label encoder and return transformed labels    |
| [`inverse_transform`](#cuml.dask.preprocessing.LabelBinarizer.inverse_transform)(y[, threshold]) | Invert a set of encoded labels back to original labels |
| [`transform`](#cuml.dask.preprocessing.LabelBinarizer.transform)(y)                      | Transform and return encoded labels                    |

### Examples

Create an array with labels and dummy encode them

```python
>>> import cupy as cp
>>> import cupyx
>>> from cuml.dask.preprocessing import LabelBinarizer

>>> from dask_cuda import LocalCUDACluster
>>> from dask.distributed import Client
>>> import dask

>>> cluster = LocalCUDACluster()
>>> client = Client(cluster)

>>> labels = cp.asarray([0, 5, 10, 7, 2, 4, 1, 0, 0, 4, 3, 2, 1],
...                     dtype=cp.int32)
>>> labels = dask.array.from_array(labels)

>>> lb = LabelBinarizer()
>>> encoded = lb.fit_transform(labels)
>>> print(encoded.compute())
[[1 0 0 0 0 0 0 0]
[0 0 0 0 0 1 0 0]
[0 0 0 0 0 0 0 1]
[0 0 0 0 0 0 1 0]
[0 0 1 0 0 0 0 0]
[0 0 0 0 1 0 0 0]
[0 1 0 0 0 0 0 0]
[1 0 0 0 0 0 0 0]
[1 0 0 0 0 0 0 0]
[0 0 0 0 1 0 0 0]
[0 0 0 1 0 0 0 0]
[0 0 1 0 0 0 0 0]
[0 1 0 0 0 0 0 0]]
>>> decoded = lb.inverse_transform(encoded)
>>> print(decoded.compute())
[ 0  5 10  7  2  4  1  0  0  4  3  2  1]
>>> client.close()
>>> cluster.close()
```

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

#### fit(y)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/preprocessing/label.py#L95)

Fit label binarizer

* **Parameters:**
  **y**
  : chunked by row.
    Target values. The 2-d matrix should only contain 0 and 1,
    represents multilabel classification.
* **Returns:**
  **self**

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

#### fit_transform(y)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/preprocessing/label.py#L122)

Fit the label encoder and return transformed labels

* **Parameters:**
  **y**
  : target values. The 2-d matrix should only contain 0 and 1,
    represents multilabel classification.
* **Returns:**
  **arr**

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

#### get_combined_model()[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/common/base.py#L57)

Return single-GPU model for serialization

* **Returns:**
  **model**
  : yet been trained.

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

#### inverse_transform(y, threshold=None)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/preprocessing/label.py#L160)

Invert a set of encoded labels back to original labels

* **Parameters:**
  **y**
  : labels

  **threshold**
* **Returns:**
  **arr**

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

#### transform(y)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/preprocessing/label.py#L139)

Transform and return encoded labels

* **Parameters:**
  **y**
* **Returns:**
  **arr**

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