def test_make_classification(self):
     X, y = make_classification(random_state=42)
     pipe = PipelineCache([('pca', PCA(2)),
                           ('lr', LogisticRegression())],
                          'cache__')
     pipe.fit(X, y)
     cache = MLCache.get_cache('cache__')
     self.assertEqual(len(cache), 1)
     key = list(cache.keys())[0]
     self.assertIn("[('X',", key)
     self.assertIn("('copy', 'True')", key)
     MLCache.remove_cache('cache__')
示例#2
0
    def test_make_classification(self):
        X, y = make_classification(random_state=42)

        pipe0 = Pipeline([('pca', PCA(2)), ('lr', LogisticRegression())])
        pipe = PipelineCache([('pca', PCA(2)), ('lr', LogisticRegression())],
                             'cache__')

        if hasattr(pipe0, '_check_fit_params'):
            pars0 = pipe0._check_fit_params()  # pylint: disable=W0212,E1101
            pars1 = pipe._check_fit_params()  # pylint: disable=W0212,E1101
            self.assertEqual(pars0, pars1)

        pipe0.fit(X, y)
        pipe.fit(X, y)
        cache = MLCache.get_cache('cache__')
        self.assertEqual(len(cache), 1)
        key = list(cache.keys())[0]
        self.assertIn("[('X',", key)
        self.assertIn("('copy', 'True')", key)
        MLCache.remove_cache('cache__')