Beispiel #1
0
def test_fail_minibatches():
    lr = TfSoftmaxRegression(epochs=100,
                             eta=0.5,
                             minibatches=13,
                             random_seed=1)
    lr.fit(X, y)
    assert((y == lr.predict(X)).all())
Beispiel #2
0
def test_fail_minibatches():
    lr = TfSoftmaxRegression(epochs=100,
                             eta=0.5,
                             minibatches=13,
                             random_seed=1)
    lr.fit(X, y)
    assert ((y == lr.predict(X)).all())
Beispiel #3
0
def test_multi_logistic_regression_gd_acc():
    lr = TfSoftmaxRegression(epochs=100,
                             eta=0.5,
                             minibatches=1,
                             random_seed=1)
    lr.fit(X, y)
    assert((y == lr.predict(X)).all())
Beispiel #4
0
def test_binary_logistic_regression_gd():
    t = np.array([[-0.28, 0.95], [-2.23, 2.4]])
    lr = TfSoftmaxRegression(epochs=100, eta=0.5, minibatches=1, random_seed=1)

    lr.fit(X_bin, y_bin)
    np.testing.assert_almost_equal(lr.weights_, t, 2)
    assert (y_bin == lr.predict(X_bin)).all()
Beispiel #5
0
def test_init_params():
    t = np.array([[-0.28, 0.95], [-2.23, 2.4]])
    lr = TfSoftmaxRegression(epochs=50, eta=0.5, minibatches=1, random_seed=1)

    lr.fit(X_bin, y_bin)
    lr.fit(X_bin, y_bin, init_params=False)
    np.testing.assert_almost_equal(lr.w_, t, 2)
    assert (y_bin == lr.predict(X_bin)).all()
Beispiel #6
0
def test_binary_logistic_regression_sgd():
    t = np.array([[0.35, 0.32], [-7.14, 7.3]])
    lr = TfSoftmaxRegression(epochs=100,
                             eta=0.5,
                             minibatches=len(y_bin),
                             random_seed=1)

    lr.fit(X_bin, y_bin)  # 0, 1 class
    np.testing.assert_almost_equal(lr.weights_, t, 2)
    assert (y_bin == lr.predict(X_bin)).all()
Beispiel #7
0
def test_binary_logistic_regression_sgd():
    t = np.array([[0.35, 0.32],
                  [-7.14, 7.3]])
    lr = TfSoftmaxRegression(epochs=100,
                             eta=0.5,
                             minibatches=len(y_bin),
                             random_seed=1)

    lr.fit(X_bin, y_bin)  # 0, 1 class
    np.testing.assert_almost_equal(lr.weights_, t, 2)
    assert((y_bin == lr.predict(X_bin)).all())
Beispiel #8
0
def test_binary_logistic_regression_gd():
    t = np.array([[-0.28, 0.95],
                  [-2.23, 2.4]])
    lr = TfSoftmaxRegression(epochs=100,
                             eta=0.5,
                             minibatches=1,
                             random_seed=1)

    lr.fit(X_bin, y_bin)
    np.testing.assert_almost_equal(lr.weights_, t, 2)
    assert((y_bin == lr.predict(X_bin)).all())
def test_init_params():
    t = np.array([[-0.28, 0.95],
                  [-2.23, 2.4]])
    lr = TfSoftmaxRegression(epochs=50,
                             eta=0.5,
                             minibatches=1,
                             random_seed=1)

    lr.fit(X_bin, y_bin)
    lr.fit(X_bin, y_bin, init_params=False)
    np.testing.assert_almost_equal(lr.w_, t, 2)
    assert (y_bin == lr.predict(X_bin)).all()
Beispiel #10
0
def _clf_softmax(trX, teX, trY, teY):
    print "factors", factors(trX.shape[0])
    print "enter no of mini batch"
    trY = trY.astype(int)
    teY = teY.astype(int)
    mini_batch = int(input())
    clf = TfSoftmaxRegression(eta=0.75,
                              epochs=100,
                              print_progress=True,
                              minibatches=mini_batch,
                              random_seed=1)
    clf.fit(trX, trY)
    pred = clf.predict(teX)
    print _f_count(teY), "test f count"
    pred = pred.astype(np.int32)
    print _f_count(pred), "pred f count"
    conf_mat = confusion_matrix(teY, pred)
    process_cm(conf_mat, to_print=True)
    print precision_score(teY, pred), "Precision Score"
    print recall_score(teY, pred), "Recall Score"
    print roc_auc_score(teY, pred), "ROC_AUC"
def _clf_softmax(trX,teX,trY,teY):
	print "factors",factors(trX.shape[0])
	print "enter no of mini batch"
	trY=trY.astype(int)
	teY=teY.astype(int)
	mini_batch=int(input())
	clf = TfSoftmaxRegression(eta=0.75, 
                         epochs=100, 
                         print_progress=True, 
                         minibatches=mini_batch, 
                         random_seed=1)
	clf.fit(trX, trY)
	pred=clf.predict(teX)
	print _f_count(teY),"test f count"
	pred=pred.astype(np.int32)
	print _f_count(pred),"pred f count"
	conf_mat=confusion_matrix(teY, pred)
	process_cm(conf_mat, to_print=True)
	print precision_score(teY,pred),"Precision Score"
	print recall_score(teY,pred),"Recall Score"
	print roc_auc_score(teY,pred), "ROC_AUC"
Beispiel #12
0
def test_multi_logistic_regression_gd_acc():
    lr = TfSoftmaxRegression(epochs=100, eta=0.5, minibatches=1, random_seed=1)
    lr.fit(X, y)
    assert (y == lr.predict(X)).all()