Ejemplo n.º 1
0
 def test_target_regressor_permute(self):
     tt = TransformedTargetRegressor2(regressor=None, transformer='permute')
     X = numpy.arange(4).reshape(-1, 1)
     y = numpy.exp(2 * X).ravel()
     tt.fit(X, y)
     self.assertIn("TransformedTargetRegressor2", str(tt))
     yp = tt.predict(X)
     self.assertEqual(yp.shape, (4, ))
     sc = tt.score(X, y)
     self.assertLesser(sc, 1.)
Ejemplo n.º 2
0
 def test_target_regressor(self):
     tt = TransformedTargetRegressor2(regressor=None, transformer='log')
     X = numpy.arange(4).reshape(-1, 1)
     y = numpy.exp(2 * X).ravel()
     tt.fit(X, y)
     self.assertIn("TransformedTargetRegressor2", str(tt))
     coef = tt.regressor_.coef_
     self.assertEqualArray(coef, numpy.array([2], dtype=float))
     yp = tt.predict(X)
     self.assertEqual(yp.shape, (4, ))
     sc = tt.score(X, y)
     self.assertLesser(sc, 1.)
Ejemplo n.º 3
0
 def test_target_regressor_err(self):
     tt = TransformedTargetRegressor2(regressor=None, transformer=None)
     X = numpy.arange(4).reshape(-1, 1)
     y = numpy.exp(2 * X).ravel()
     self.assertRaise(lambda: tt.fit(X, y), TypeError)