def test_tovw():
    x = np.array([[1.2, 3.4, 5.6, 1.0, 10], [7.8, 9.10, 11, 0, 20]])
    y = np.array([1, -1])
    w = [1, 2]

    expected = ["1 1 | 0:1.2 1:3.4 2:5.6 3:1 4:10", "-1 2 | 0:7.8 1:9.1 2:11 4:20"]

    assert tovw(x=x, y=y, sample_weight=w) == expected

    assert tovw(x=csr_matrix(x), y=y, sample_weight=w) == expected
Esempio n. 2
0
def test_tovw():
    x = np.array([[1.2, 3.4, 5.6, 1.0, 10], [7.8, 9.10, 11, 0, 20]])
    y = np.array([1, -1])
    w = [1, 2]

    expected = ['1 1 | 0:1.2 1:3.4 2:5.6 3:1 4:10',
                '-1 2 | 0:7.8 1:9.1 2:11 4:20']

    assert tovw(x=x, y=y, sample_weight=w) == expected

    assert tovw(x=csr_matrix(x), y=y, sample_weight=w) == expected
Esempio n. 3
0
def test_tovw():
    x = np.array([[1.2, 3.4, 5.6], [7.8, 9.10, 11.]])
    y = np.array([1, -1])
    w = [1, 2]

    expected = ['1 1 | 0:1.2 1:3.4 2:5.6',
                '-1 2 | 0:7.8 1:9.1 2:11']

    assert tovw(x=x, y=y, sample_weight=w) == expected