Beispiel #1
0
    def test_FitPredict__predict(self):
        X = self.X
        y = self.y
        lm = LinearRegression()
        lm_strategy = AdapterForFitPredictAdaptee(lm)
        lm_strategy.fit(X=X, y=y)
        result_lm = lm_strategy.predict(X=X)
        self.assertEqual(list(result_lm.keys()), ['predict'])
        self.assertEqual(result_lm['predict'].shape, (self.size, 1))

        gm = GaussianMixture()
        gm_strategy = AdapterForFitPredictAdaptee(gm)
        gm_strategy.fit(X=X)
        result_gm = gm_strategy.predict(X=X)
        self.assertEqual(sorted(list(result_gm.keys())),
                         sorted(['predict', 'predict_proba']))
        self.assertEqual(result_gm['predict'].shape, (self.size, ))
Beispiel #2
0
 def test_baseadapter__fit_AdapterForFitPredictAdaptee(self):
     X = self.X
     y = self.y
     lm = LinearRegression()
     stepstrategy = AdapterForFitPredictAdaptee(lm)
     self.assertEqual(hasattr(stepstrategy._adaptee, 'coef_'), False)
     result = stepstrategy.fit(X=X, y=y)
     self.assertEqual(hasattr(stepstrategy._adaptee, 'coef_'), True)
     self.assertEqual(stepstrategy, result)