Exemplo n.º 1
0
def test_multiclass_hinge_sgd():
    for data in (mult_dense, mult_csr):
        for fit_intercept in (True, False):
            clf = SGDClassifier(loss="hinge", multiclass=True,
                                fit_intercept=fit_intercept, random_state=0)
            clf.fit(data, mult_target)
            assert_greater(clf.score(data, mult_target), 0.78)
Exemplo n.º 2
0
def test_multiclass_hinge_sgd_l1l2():
    for data in (mult_dense, mult_csr):
        clf = SGDClassifier(loss="hinge",
                            penalty="l1/l2",
                            multiclass=True,
                            random_state=0)
        clf.fit(data, mult_target)
        assert_greater(clf.score(data, mult_target), 0.75)
Exemplo n.º 3
0
def test_multiclass_hinge_sgd_l1l2(data, request):
    X, y = request.getfixturevalue(data)
    clf = SGDClassifier(loss="hinge",
                        penalty="l1/l2",
                        multiclass=True,
                        random_state=0)
    clf.fit(X, y)
    assert clf.score(X, y) > 0.75
Exemplo n.º 4
0
def test_multiclass_hinge_sgd(data, fit_intercept, request):
    X, y = request.getfixturevalue(data)
    clf = SGDClassifier(loss="hinge",
                        multiclass=True,
                        fit_intercept=fit_intercept,
                        random_state=0)
    clf.fit(X, y)
    assert clf.score(X, y) > 0.78
Exemplo n.º 5
0
def test_multiclass_squared_hinge_sgd():
    for data in (mult_dense, mult_csr):
        for fit_intercept in (True, False):
            clf = SGDClassifier(loss="squared_hinge", multiclass=True,
                                learning_rate="constant", eta0=1e-3,
                                fit_intercept=fit_intercept, random_state=0)
            clf.fit(data, mult_target)
            assert_greater(clf.score(data, mult_target), 0.78)
Exemplo n.º 6
0
def test_multiclass_squared_hinge_sgd(data, fit_intercept, request):
    X, y = request.getfixturevalue(data)
    clf = SGDClassifier(loss="squared_hinge",
                        multiclass=True,
                        learning_rate="constant",
                        eta0=1e-3,
                        fit_intercept=fit_intercept,
                        random_state=0)
    clf.fit(X, y)
    assert clf.score(X, y) > 0.78
Exemplo n.º 7
0
def test_multiclass_sgd():
    clf = SGDClassifier(random_state=0)
    clf.fit(mult_dense, mult_target)
    assert_greater(clf.score(mult_dense, mult_target), 0.80)
    assert_equal(list(clf.classes_), [0, 1, 2])
Exemplo n.º 8
0
def test_multiclass_hinge_sgd_l1l2():
    for data in (mult_dense, mult_csr):
        clf = SGDClassifier(loss="hinge", penalty="l1/l2", multiclass=True, random_state=0)
        clf.fit(data, mult_target)
        assert_greater(clf.score(data, mult_target), 0.75)
Exemplo n.º 9
0
def test_multiclass_sgd():
    clf = SGDClassifier(random_state=0)
    clf.fit(mult_dense, mult_target)
    assert_greater(clf.score(mult_dense, mult_target), 0.80)
Exemplo n.º 10
0
def test_multiclass_sgd():
    clf = SGDClassifier(random_state=0)
    clf.fit(mult_dense, mult_target)
    assert_greater(clf.score(mult_dense, mult_target), 0.80)
Exemplo n.º 11
0
def test_multiclass_sgd():
    clf = SGDClassifier(random_state=0)
    clf.fit(mult_dense, mult_target)
    assert clf.score(mult_dense, mult_target) > 0.80
    assert list(clf.classes_) == [0, 1, 2]
Exemplo n.º 12
0
def test_multiclass_sgd():
    clf = SGDClassifier(random_state=0)
    clf.fit(mult_dense, mult_target)
    assert_greater(clf.score(mult_dense, mult_target), 0.80)
    assert_equal(list(clf.classes_), [0, 1, 2])