Esempio n. 1
0
def test_binary_sgd_step_size0():
    rstate = RandomState(42)
    n_features = 20

    X, y = get_fake_data(100, n_features, rstate)

    clf = get_new_model(n_features, rstate)
    best = find_sgd_step_size0(clf, X, y, (.25, .5))
    assert_almost_equal(best, -4.9927, decimal=4)

    # start a little lower, still works
    best = find_sgd_step_size0(clf, X, y, (.125, .25))
    assert_almost_equal(best, -4.6180, decimal=4)

    # find_sgd_step_size0 does not change clf
    assert clf.sgd_step_size0 == 1000.0
Esempio n. 2
0
def test_binary_sgd_step_size0():
    rstate = RandomState(42)
    n_features = 20

    X, y = get_fake_data(100, n_features, rstate)

    clf = get_new_model(n_features, rstate)
    best = find_sgd_step_size0(clf, X, y, (.25, .5))
    assert_almost_equal(best, -4.9927, decimal=4)

    # start a little lower, still works
    best = find_sgd_step_size0(clf, X, y, (.125, .25))
    assert_almost_equal(best, -4.6180, decimal=4)

    # find_sgd_step_size0 does not change clf
    assert clf.sgd_step_size0 == 1000.0
Esempio n. 3
0
def test_binary_fit():
    rstate = RandomState(42)
    n_features = 20

    for L in [100, DEFAULT_MAX_EXAMPLES, int(DEFAULT_MAX_EXAMPLES * 1.5),
            int(DEFAULT_MAX_EXAMPLES * 3)]:

        clf = get_new_model(n_features, rstate, L)
        X, y = get_fake_data(L, n_features, rstate, separation=0.1)
        best = find_sgd_step_size0(clf, (X, y))
        _clf = binary_fit(clf, (X, y))
        assert _clf is clf
        assert 0 < clf.sgd_step_size0 <= best
Esempio n. 4
0
def test_binary_sgd_step_size0():
    rstate = RandomState(42)
    n_features = 20

    X, y = get_fake_data(100, n_features, rstate)

    clf = get_new_model(n_features, rstate, 100)
    best0 = find_sgd_step_size0(clf, (X, y))
    print best0
    assert np.allclose(best0, 0.04, atol=.1, rtol=.5)

    # find_sgd_step_size0 does not change clf
    assert clf.sgd_step_size0 == 1000.0