Exemplo n.º 1
0
def test_clf_single():
    est = FMClassifier(verbose=0, seed=13, num_iter=2).fit(X, y)
    out = est.predict(X[:1])
    assert isinstance(out, np.ndarray)
    out = est.predict_proba(X[:1])
    assert isinstance(out, np.ndarray)
    assert out.shape == (1, 2)
Exemplo n.º 2
0
def test_smoke_classification():
    for X_ in (X, sp.csc_matrix(X), sp.csr_matrix(X), sp.coo_matrix(X)):
        for lr in ['optimal', 'invscaling', 'constant']:
            est = FMClassifier(verbose=0, seed=13, num_iter=2, learning_rate_schedule=lr).fit(X_, y)
            proba = est.predict_proba(X_)
            assert proba.shape == (n, 2)
            np.testing.assert_array_almost_equal(proba[:3], np.array([[0.45637266, 0.54362734],
                                                                      [0.47387578, 0.52612422],
                                                                      [0.48227419, 0.51772581]]))

            pred = est.predict(X_)
            assert pred.shape == (n, )
            np.testing.assert_array_almost_equal(pred[:5], np.ones(5))