Exemplo n.º 1
0
def test_directional_bars():
    X, Y = generate_easy(n_samples=10, noise=5, box_size=2, total_size=6, seed=1)
    n_labels = 2
    crf = LatentDirectionalGridCRF(n_labels=n_labels, n_states_per_label=[1, 4])
    clf = LatentSSVM(OneSlackSSVM(model=crf, max_iter=500, C=10.0, inference_cache=50, tol=0.01))
    clf.fit(X, Y)
    Y_pred = clf.predict(X)

    assert_array_equal(np.array(Y_pred), Y)
Exemplo n.º 2
0
def test_directional_bars():
    # this test is very fragile :-/
    X, Y = generate_easy(n_samples=20, noise=2, box_size=2, total_size=6,
                         seed=2)
    n_labels = 2
    crf = LatentDirectionalGridCRF(n_labels=n_labels,
                                   n_states_per_label=[1, 4])
    clf = SubgradientLatentSSVM(model=crf, max_iter=75, C=10.,
                                learning_rate=1, momentum=0,
                                decay_exponent=0.5, decay_t0=10)
    clf.fit(X, Y)
    Y_pred = clf.predict(X)

    assert_array_equal(np.array(Y_pred), Y)
Exemplo n.º 3
0
def test_directional_bars():
    X, Y = generate_easy(n_samples=10,
                         noise=5,
                         box_size=2,
                         total_size=6,
                         seed=1)
    n_labels = 2
    crf = LatentDirectionalGridCRF(n_labels=n_labels,
                                   n_states_per_label=[1, 4])
    clf = LatentSSVM(
        OneSlackSSVM(model=crf,
                     max_iter=500,
                     C=10.,
                     inference_cache=50,
                     tol=.01))
    clf.fit(X, Y)
    Y_pred = clf.predict(X)

    assert_array_equal(np.array(Y_pred), Y)