Exemplo n.º 1
0
def test_normal_equation():
    t1 = np.array([[-0.08], [1.02]])
    b1 = np.array([0.00])
    ada = Adaline(epochs=30, eta=0.01, minibatches=None, random_seed=None)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, decimal=2)
    np.testing.assert_almost_equal(ada.b_, b1, decimal=2)
    assert (y1 == ada.predict(X_std)).all(), ada.predict(X_std)
Exemplo n.º 2
0
def test_normal_equation():
    t1 = np.array([[-0.08], [1.02]])
    b1 = np.array([0.00])
    ada = Adaline(epochs=30,
                  eta=0.01,
                  minibatches=None,
                  random_seed=None)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, decimal=2)
    np.testing.assert_almost_equal(ada.b_, b1, decimal=2)
    assert (y1 == ada.predict(X_std)).all(), ada.predict(X_std)
Exemplo n.º 3
0
def test_refit_weights():
    t1 = np.array([-5.21e-16,  -7.86e-02,   1.02e+00])
    ada = Adaline(epochs=15, eta=0.01, solver='gd', random_seed=1)
    ada.fit(X_std, y1, init_weights=True)
    ada.fit(X_std, y1, init_weights=False)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert((y1 == ada.predict(X_std)).all())
Exemplo n.º 4
0
def test_0_1_class():

    t1 = np.array([0.51, -0.04,  0.51])
    ada = Adaline(epochs=30, eta=0.01, learning='sgd', random_seed=1)
    ada.fit(X_std, y0)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert((y0 == ada.predict(X_std)).all())
Exemplo n.º 5
0
def test_stochastic_gradient_descent():

    t1 = np.array([0.03, -0.09, 1.02])
    ada = Adaline(epochs=30, eta=0.01, learning='sgd', random_seed=1)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert ((y1 == ada.predict(X_std)).all())
Exemplo n.º 6
0
def test_gradient_descent():

    t1 = np.array([-5.21e-16,  -7.86e-02,   1.02e+00])
    ada = Adaline(epochs=30, eta=0.01, learning='gd', random_seed=1)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert((y1 == ada.predict(X_std)).all())
Exemplo n.º 7
0
def test_refit_weights():
    t1 = np.array([-5.21e-16, -7.86e-02, 1.02e+00])
    ada = Adaline(epochs=15, eta=0.01, solver='gd', random_seed=1)
    ada.fit(X_std, y1, init_weights=True)
    ada.fit(X_std, y1, init_weights=False)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert ((y1 == ada.predict(X_std)).all())
Exemplo n.º 8
0
def test_0_1_class():

    t1 = np.array([0.51, -0.04, 0.51])
    ada = Adaline(epochs=30, eta=0.01, learning='sgd', random_seed=1)
    ada.fit(X_std, y0)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert ((y0 == ada.predict(X_std)).all())
Exemplo n.º 9
0
def test_refit_weights():
    t1 = np.array([[-0.08], [1.02]])
    ada = Adaline(epochs=15, eta=0.01, minibatches=1, random_seed=1)
    ada.fit(X_std, y1, init_params=True)
    ada.fit(X_std, y1, init_params=False)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert ((y1 == ada.predict(X_std)).all())
Exemplo n.º 10
0
def test_stochastic_gradient_descent():

    t1 = np.array([0.03, -0.09, 1.02])
    ada = Adaline(epochs=30, eta=0.01, learning='sgd', random_seed=1)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert((y1 == ada.predict(X_std)).all())
Exemplo n.º 11
0
def test_gradient_descent():

    t1 = np.array([-5.21e-16, -7.86e-02, 1.02e+00])
    ada = Adaline(epochs=30, eta=0.01, learning='gd', random_seed=1)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert ((y1 == ada.predict(X_std)).all())
Exemplo n.º 12
0
def test_gradient_descent():
    t1 = np.array([[-0.08], [1.02]])
    b1 = np.array([0.00])
    ada = Adaline(epochs=30, eta=0.01, minibatches=1, random_seed=1)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, decimal=2)
    np.testing.assert_almost_equal(ada.b_, b1, decimal=2)
    assert ((y1 == ada.predict(X_std)).all())
Exemplo n.º 13
0
def test_normal_equation():
    t1 = np.array([-5.21e-16,  -7.86e-02,   1.02e+00])
    ada = Adaline(epochs=30,
                  eta=0.01,
                  minibatches=None,
                  random_seed=1)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert((y1 == ada.predict(X_std)).all())
Exemplo n.º 14
0
def test_stochastic_gradient_descent():
    t1 = np.array([[-0.08], [1.02]])
    ada = Adaline(epochs=30,
                  eta=0.01,
                  minibatches=len(y),
                  random_seed=1)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert((y1 == ada.predict(X_std)).all())
Exemplo n.º 15
0
def test_standardized_iris_data_with_zero_weights():
    t1 = np.array([-5.21e-16, -7.86e-02, 1.02e+00])
    ada = Adaline(epochs=30,
                  eta=0.01,
                  solver='gd',
                  random_seed=1,
                  zero_init_weight=True)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert ((y1 == ada.predict(X_std)).all())
Exemplo n.º 16
0
def test_standardized_iris_data_with_shuffle():
    t1 = np.array([-5.21e-16,  -7.86e-02,   1.02e+00])
    ada = Adaline(epochs=30,
                  eta=0.01,
                  solver='gd',
                  random_seed=1,
                  shuffle=True)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert((y1 == ada.predict(X_std)).all())
Exemplo n.º 17
0
def test_standardized_iris_data_with_zero_weights():
    t1 = np.array([-5.21e-16,  -7.86e-02,   1.02e+00])
    ada = Adaline(epochs=30,
                  eta=0.01,
                  minibatches=1,
                  random_seed=1,
                  zero_init_weight=True)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert((y1 == ada.predict(X_std)).all())
Exemplo n.º 18
0
def test_refit_weights():
    t1 = np.array([[-0.08], [1.02]])
    ada = Adaline(epochs=15,
                  eta=0.01,
                  minibatches=1,
                  random_seed=1)
    ada.fit(X_std, y1, init_params=True)
    ada.fit(X_std, y1, init_params=False)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert((y1 == ada.predict(X_std)).all())
Exemplo n.º 19
0
def test_gradient_descent():
    t1 = np.array([[-0.08], [1.02]])
    b1 = np.array([0.00])
    ada = Adaline(epochs=30,
                  eta=0.01,
                  minibatches=1,
                  random_seed=1)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, decimal=2)
    np.testing.assert_almost_equal(ada.b_, b1, decimal=2)
    assert((y1 == ada.predict(X_std)).all())
Exemplo n.º 20
0
def test_normal_equation():
    t1 = np.array([-5.21e-16, -7.86e-02, 1.02e+00])
    ada = Adaline(epochs=30, eta=0.01, solver='normal equation', random_seed=1)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert ((y1 == ada.predict(X_std)).all())
Exemplo n.º 21
0
def test_stochastic_gradient_descent():
    t1 = np.array([[-0.08], [1.02]])
    ada = Adaline(epochs=30, eta=0.01, minibatches=len(y), random_seed=1)
    ada.fit(X_std, y1)
    np.testing.assert_almost_equal(ada.w_, t1, 2)
    assert ((y1 == ada.predict(X_std)).all())