コード例 #1
0
def test_onehot_to_sparse_singlelabel_int_raise_error():
    """It raises error when passed multilabel data without multilabel flag."""
    data = np.array([[0, 0, 0], [0, 0, 1], [1, 0, 1]])
    try:
        CM._onehot_to_sparse(data)
        raise AssertionError
    except ValueError:
        pass
    else:
        raise AssertionError
コード例 #2
0
def test_onehot_to_sparse_singlelabel_bool_raise_error():
    """It raises error when passed multilabel data without multilabel flag."""
    data = np.array([[False, False, False], [False, False, True],
                     [True, False, True]])
    try:
        CM._onehot_to_sparse(data)
        raise AssertionError
    except ValueError:
        pass
    else:
        raise AssertionError
コード例 #3
0
def test_onehot_to_sparse_multilabel_bool():
    """It returns expected sparse labels."""
    data = np.array([[False, False, False], [False, False, True],
                     [True, False, True]])
    assert CM._onehot_to_sparse(data, multilabel=True) == [[], [2], [0, 2]]
コード例 #4
0
def test_onehot_to_sparse_multilabel_int():
    """It returns expected sparse labels."""
    data = np.array([[0, 0, 0], [0, 0, 1], [1, 0, 1]])
    assert CM._onehot_to_sparse(data, multilabel=True) == [[], [2], [0, 2]]
コード例 #5
0
def test_onehot_to_sparse_singlelabel_bool():
    """It returns expected sparse labels when passed bool onehot encoded labels."""
    data = np.array([[False, False, True], [False, True, False],
                     [True, False, False]])
    assert CM._onehot_to_sparse(data) == [2, 1, 0]
コード例 #6
0
def test_onehot_to_sparse_singlelabel_int():
    """It returns expected sparse labels when passed integer onehot encoded labels."""
    data = np.array([[0, 0, 1], [0, 1, 0], [1, 0, 0]])
    assert CM._onehot_to_sparse(data) == [2, 1, 0]