Beispiel #1
0
 def test_fit_predict_2_layers_reg(self):
     model = Stack([layer_width2_reg, layer_width1_reg])
     X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])
     y = np.dot(X, np.array([1, 2])) + 3
     model.fit(X, y)
     result = model.predict(np.array([[3, 5],[3, 5]]))
     assert result.shape == (2,)
     assert np.allclose(result, np.array([16, 16]))
Beispiel #2
0
 def test_fit_predict_2_layers_clf(self):
     model = Stack([layer_width2_clf, layer_width1_clf])
     X = np.array([[1, 1], [1, 1], [0, 0], [0, 0]])
     y = np.array([1, 1, 0, 0])
     model.fit(X, y)
     result = model.predict(np.array([[1, 1]]))
     assert result.shape == (1,)
     assert np.allclose(result, np.array([1]))
Beispiel #3
0
 def test_fit_predict_stack_with_sklearn_folds(self):
     model = Stack([layer_width2_reg, layer_width1_reg], folds=KFold(2))
     X = np.array([[1, 1], [1, 2], [2, 2], [2, 3], [1, 1], [1, 2], [2, 2],
                   [2, 3]])
     y = np.dot(X, np.array([1, 2])) + 3
     model.fit(X, y)
     result = model.predict(np.array([[3, 5], [3, 5]]))
     assert result.shape == (2, )
     assert np.allclose(result, np.array([16, 16]))