Exemple #1
0
def test_sdca_hinge_elastic():
    clf = SDCAClassifier(alpha=0.5,
                         l1_ratio=0.85,
                         loss="hinge",
                         random_state=0)
    clf.fit(X_bin, y_bin)
    assert clf.score(X_bin, y_bin) == 1.0
Exemple #2
0
def test_sdca_hinge_multiclass():
    clf = SDCAClassifier(alpha=1e-2,
                         max_iter=100,
                         loss="hinge",
                         random_state=0)
    clf.fit(X, y)
    assert_almost_equal(clf.score(X, y), 0.947, 3)
Exemple #3
0
def test_sdca_squared_hinge_elastic():
    clf = SDCAClassifier(alpha=0.5,
                         l1_ratio=0.85,
                         loss="squared_hinge",
                         random_state=0)
    clf.fit(X_bin, y_bin)
    assert_equal(clf.score(X_bin, y_bin), 1.0)
def test_sdca_squared_hinge_elastic(bin_train_data):
    X_bin, y_bin = bin_train_data
    clf = SDCAClassifier(alpha=0.5,
                         l1_ratio=0.85,
                         loss="squared_hinge",
                         random_state=0)
    clf.fit(X_bin, y_bin)
    assert clf.score(X_bin, y_bin) == 1.0
Exemple #5
0
def test_sdca_smooth_hinge_elastic():
    clf = SDCAClassifier(alpha=0.5,
                         l1_ratio=0.85,
                         loss="smooth_hinge",
                         random_state=0)
    clf.fit(X_bin, y_bin)
    assert not hasattr(clf, 'predict_proba')
    assert_equal(clf.score(X_bin, y_bin), 1.0)
def test_sdca_hinge_multiclass(train_data):
    X, y = train_data
    clf = SDCAClassifier(alpha=1e-2,
                         max_iter=100,
                         loss="hinge",
                         random_state=0)
    clf.fit(X, y)
    np.testing.assert_almost_equal(clf.score(X, y), 0.933, 3)
def test_sdca_smooth_hinge_elastic(bin_train_data):
    X_bin, y_bin = bin_train_data
    clf = SDCAClassifier(alpha=0.5,
                         l1_ratio=0.85,
                         loss="smooth_hinge",
                         random_state=0)
    clf.fit(X_bin, y_bin)
    assert not hasattr(clf, 'predict_proba')
    assert clf.score(X_bin, y_bin) == 1.0
Exemple #8
0
def test_sdca_squared_l1_only():
    clf = SDCAClassifier(alpha=0.5,
                         l1_ratio=1.0,
                         loss="squared",
                         tol=1e-2,
                         max_iter=100,
                         random_state=0)
    clf.fit(X_bin, y_bin)
    assert_equal(clf.score(X_bin, y_bin), 1.0)
Exemple #9
0
def test_sdca_smooth_hinge_l1_only():
    clf = SDCAClassifier(alpha=0.5,
                         l1_ratio=1.0,
                         loss="smooth_hinge",
                         tol=1e-2,
                         max_iter=200,
                         random_state=0)
    clf.fit(X_bin, y_bin)
    assert clf.score(X_bin, y_bin) == 1.0
def test_sdca_squared_l1_only(bin_train_data):
    X_bin, y_bin = bin_train_data
    clf = SDCAClassifier(alpha=0.5,
                         l1_ratio=1.0,
                         loss="squared",
                         tol=1e-2,
                         max_iter=100,
                         random_state=0)
    clf.fit(X_bin, y_bin)
    assert clf.score(X_bin, y_bin) == 1.0
Exemple #11
0
def test_sdca_absolute():
    clf = SDCAClassifier(loss="absolute", random_state=0)
    clf.fit(X_bin, y_bin)
    assert not hasattr(clf, 'predict_proba')
    assert_equal(clf.score(X_bin, y_bin), 1.0)
Exemple #12
0
def test_sdca_hinge_multiclass():
    clf = SDCAClassifier(alpha=1e-2, max_iter=100, loss="hinge",
                              random_state=0)
    clf.fit(X, y)
    assert_almost_equal(clf.score(X, y), 0.947, 3)
Exemple #13
0
def test_sdca_squared():
    clf = SDCAClassifier(loss="squared", random_state=0)
    clf.fit(X_bin, y_bin)
    assert_equal(clf.score(X_bin, y_bin), 1.0)
Exemple #14
0
def test_sdca_absolute():
    clf = SDCAClassifier(loss="absolute", random_state=0)
    clf.fit(X_bin, y_bin)
    assert not hasattr(clf, 'predict_proba')
    assert_equal(clf.score(X_bin, y_bin), 1.0)
Exemple #15
0
def test_sdca_absolute():
    clf = SDCAClassifier(loss="absolute", random_state=0)
    clf.fit(X_bin, y_bin)
    assert_equal(clf.score(X_bin, y_bin), 1.0)
Exemple #16
0
def test_sdca_squared_hinge_elastic():
    clf = SDCAClassifier(alpha=0.5, l1_ratio=0.85, loss="squared_hinge",
                              random_state=0)
    clf.fit(X_bin, y_bin)
    assert_equal(clf.score(X_bin, y_bin), 1.0)
Exemple #17
0
def test_sdca_squared():
    clf = SDCAClassifier(loss="squared", random_state=0)
    clf.fit(X_bin, y_bin)
    assert not hasattr(clf, 'predict_proba')
    assert clf.score(X_bin, y_bin) == 1.0
def test_sdca_hinge(bin_train_data):
    X_bin, y_bin = bin_train_data
    clf = SDCAClassifier(loss="hinge", random_state=0)
    clf.fit(X_bin, y_bin)
    assert not hasattr(clf, 'predict_proba')
    assert clf.score(X_bin, y_bin) == 1.0
Exemple #19
0
def test_sdca_absolute_l1_only():
    clf = SDCAClassifier(alpha=0.5, l1_ratio=1.0, loss="absolute",
                              tol=1e-2, max_iter=200, random_state=0)
    clf.fit(X_bin, y_bin)
    assert_equal(clf.score(X_bin, y_bin), 1.0)
Exemple #20
0
def test_sdca_smooth_hinge_elastic():
    clf = SDCAClassifier(alpha=0.5, l1_ratio=0.85, loss="smooth_hinge",
                              random_state=0)
    clf.fit(X_bin, y_bin)
    assert not hasattr(clf, 'predict_proba')
    assert_equal(clf.score(X_bin, y_bin), 1.0)
Exemple #21
0
def test_sdca_squared():
    clf = SDCAClassifier(loss="squared", random_state=0)
    clf.fit(X_bin, y_bin)
    assert_equal(clf.score(X_bin, y_bin), 1.0)
Exemple #22
0
import sys

from sklearn.externals import joblib

from lightning.classification import SDCAClassifier

if len(sys.argv) == 1:
    print """
    Please enter the path to amazon7_uncompressed_pkl/amazon7.pkl

    Download data from
    http://www.mblondel.org/data/amazon7_uncompressed_pkl.tar.bz2
    """
    exit()

data = joblib.load(sys.argv[1], mmap_mode="r")
X = data["X"]
y = data["y"].copy()  # copy is needed to modify y.

y[y >= 1] = 1  # Create a binary classification problem.

clf = SDCAClassifier(tol=1e-5, max_iter=10, verbose=1)
clf.fit(X, y)
print clf.score(X, y)
Exemple #23
0
def test_sdca_absolute():
    clf = SDCAClassifier(loss="absolute", random_state=0)
    clf.fit(X_bin, y_bin)
    assert_equal(clf.score(X_bin, y_bin), 1.0)