pycredits.label_mapper

Module Contents

Functions

map_labels_to_binary(y)

Transforms an array values by converting 1s to 0s and 2s to 1s

pycredits.label_mapper.map_labels_to_binary(y)[source]

Transforms an array values by converting 1s to 0s and 2s to 1s

Parameters:

ynumpy.ndarray

An array containing the label values. Expected values are 1 or 2.

Returns:

numpy.ndarray

An array where all original values of 1 are replaced with 0 and all original values of 2 are replaced with 1.

Raises:

ValueError

If the input array contains any values other than 1 or 2.

Examples:

>>> import numpy as np
>>> y = np.array([1, 2, 1, 2, 2])
>>> map_labels_to_binary(y)
array([0, 1, 0, 1, 1])