Example #1
0
def test_fit_rbf_binary_early_stopping():
    clf = DualSVC(loss="l1", kernel="rbf", gamma=0.5, random_state=0,
                  shrinking=True, selection="loss",
                  termination="n_sv", sv_upper_bound=30)
    clf.fit(bin_dense, bin_target)
    y_pred = clf.predict(bin_dense)
    assert_equal(clf.dual_coef_.shape[1], 30)
Example #2
0
def test_fit_rbf_binary():
    for shrinking in (True, False):
        for selection in ("loss", "permute", "active"):
            for loss in ("l1", "l2"):
                clf = DualSVC(loss=loss, kernel="rbf", gamma=0.1, random_state=0,
                              shrinking=shrinking, selection=selection)
                clf.fit(bin_dense, bin_target)
                y_pred = clf.predict(bin_dense)
                assert_equal(np.mean(y_pred == bin_target), 1.0)
Example #3
0
def test_fit_rbf_multi():
    clf = DualSVC(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)