Beispiel #1
0
def test_naive_asgd_with_feedback():
    n_points = 1e3
    n_features = 1e2
    X, y = get_fake_data(n_points, n_features, 42)
    Xtst, ytst = get_fake_data(n_points, n_features, 43)

    clf = ASGD(n_features, sgd_step_size0=1e-3, l2_regularization=1e-6,
               n_iterations=4, feedback=True, dtype=np.float32)
    clf.fit(X, y)
    ytrn_preds = clf.predict(X)
    ytst_preds = clf.predict(Xtst)
    ytrn_acc = (ytrn_preds==y).mean()
    ytst_acc = (ytst_preds==y).mean()
    assert_equal(ytrn_acc, 0.707)
    assert_equal(ytst_acc, 0.505)
Beispiel #2
0
def test_naive_asgd():

    rstate = RandomState(42)

    X, y = get_fake_data(N_POINTS, N_FEATURES, rstate)
    Xtst, ytst = get_fake_data(N_POINTS, N_FEATURES, rstate)

    clf = BinaryASGD(*DEFAULT_ARGS, rstate=rstate, **DEFAULT_KWARGS)

    clf.fit(X, y)
    ytrn_preds = clf.predict(X)
    ytst_preds = clf.predict(Xtst)
    ytrn_acc = (ytrn_preds == y).mean()
    ytst_acc = (ytst_preds == y).mean()
    assert_equal(ytrn_acc, 0.72)
    assert_equal(ytst_acc, 0.522)
Beispiel #3
0
def test_naive_asgd():

    rstate = RandomState(42)

    X, y = get_fake_data(N_POINTS, N_FEATURES, rstate)
    Xtst, ytst = get_fake_data(N_POINTS, N_FEATURES, rstate)

    clf = BinaryASGD(*DEFAULT_ARGS, rstate=rstate, **DEFAULT_KWARGS)

    clf.fit(X, y)
    ytrn_preds = clf.predict(X)
    ytst_preds = clf.predict(Xtst)
    ytrn_acc = (ytrn_preds == y).mean()
    ytst_acc = (ytst_preds == y).mean()
    assert_equal(ytrn_acc, 0.72)
    assert_equal(ytst_acc, 0.522)
Beispiel #4
0
def test_naive_asgd_with_feedback():
    raise SkipTest("FIXME: feedback support is buggy")

    rstate = RandomState(43)

    X, y = get_fake_data(N_POINTS, N_FEATURES, rstate)
    Xtst, ytst = get_fake_data(N_POINTS, N_FEATURES, rstate)

    clf = BinaryASGD(*DEFAULT_ARGS,
                     feedback=True, rstate=rstate, **DEFAULT_KWARGS)
    clf.fit(X, y)
    ytrn_preds = clf.predict(X)
    ytst_preds = clf.predict(Xtst)
    ytrn_acc = (ytrn_preds == y).mean()
    ytst_acc = (ytst_preds == y).mean()
    assert_equal(ytrn_acc, 0.709)
    assert_equal(ytst_acc, 0.449)
Beispiel #5
0
def test_naive_asgd_with_feedback():
    raise SkipTest("FIXME: feedback support is buggy")

    rstate = RandomState(43)

    X, y = get_fake_data(N_POINTS, N_FEATURES, rstate)
    Xtst, ytst = get_fake_data(N_POINTS, N_FEATURES, rstate)

    clf = BinaryASGD(*DEFAULT_ARGS,
                     feedback=True,
                     rstate=rstate,
                     **DEFAULT_KWARGS)
    clf.fit(X, y)
    ytrn_preds = clf.predict(X)
    ytst_preds = clf.predict(Xtst)
    ytrn_acc = (ytrn_preds == y).mean()
    ytst_acc = (ytst_preds == y).mean()
    assert_equal(ytrn_acc, 0.709)
    assert_equal(ytst_acc, 0.449)