Esempio n. 1
0
def test_fit_rbf_binary():
    for selection in ("permute", "active", "loss"):
        clf = LaSVM(random_state=0, max_iter=2, kernel="rbf",
                    selection=selection)
        clf.fit(bin_dense, bin_target)
        acc = clf.score(bin_dense, bin_target)
        assert_almost_equal(acc, 1.0)
Esempio n. 2
0
def test_fit_linear_binary():
    for selection, exp in (("permute", 1.0),
                           ("active", 1.0),
                           ("loss", 1.0)):
        clf = LaSVM(random_state=0, max_iter=2, kernel="linear",
                    selection=selection)
        clf.fit(bin_dense, bin_target)
        acc = clf.score(bin_dense, bin_target)
        assert_almost_equal(acc, exp)
Esempio n. 3
0
def test_warm_start():
    for selection in ("permute", "active", "loss"):
        clf = LaSVM(random_state=0, max_iter=2, kernel="rbf", warm_start=True, selection=selection)
        clf.C = 0.5
        clf.fit(bin_dense, bin_target)
        acc = clf.score(bin_dense, bin_target)
        assert_almost_equal(acc, 1.0, 1)

        clf.C = 0.6
        clf.fit(bin_dense, bin_target)
        acc = clf.score(bin_dense, bin_target)
        assert_almost_equal(acc, 1.0)
Esempio n. 4
0
def test_sv_upper_bound():
    clf = LaSVM(random_state=0, max_iter=2, kernel="rbf", finish_step=True,
                termination="n_sv", sv_upper_bound=30)
    clf.fit(bin_dense, bin_target)
    n_sv = np.sum(clf.dual_coef_ != 0)
    assert_equal(n_sv, 30)
Esempio n. 5
0
def test_fit_rbf_multi():
    clf = LaSVM(kernel="rbf", gamma=0.1, random_state=0)
    clf.fit(mult_dense, mult_target)
    y_pred = clf.predict(mult_dense)
    acc = np.mean(y_pred == mult_target)
    assert_almost_equal(acc, 1.0)
Esempio n. 6
0
def test_n_components():
    clf = LaSVM(random_state=0, max_iter=2, kernel="rbf", finish_step=True, termination="n_components", n_components=30)
    clf.fit(bin_dense, bin_target)
    n_sv = np.sum(clf.coef_ != 0)
    assert_equal(n_sv, 30)