def _encode_target()

in src/utils.py [0:0]


def _encode_target(y: np.ndarray):
    # Encode the target column with the value 0 for the majority class and 1 for the minority class
    y = y.reshape((-1, 1))
    unique, counts = np.unique(y, return_counts=True)
    assert len(unique) == 2
    ret = np.zeros_like(y)
    if counts[0] > counts[1]:
        ret[y == unique[1]] = 1
    else:
        ret[y == unique[0]] = 1
    assert np.sum(ret == 0) == max(counts)
    assert np.sum(ret == 1) == min(counts)
    return ret