Beispiel #1
0
    def test_with_pandas_df(self):
        x, y = make_regression(random_state=561)
        df = pd.DataFrame(x)
        df['y'] = y

        m = ElasticNet(n_folds=3, random_state=123)
        m = m.fit(df.drop(['y'], axis=1), df.y)
        sanity_check_regression(m, x)
    def test_with_pandas_df(self):
        x, y = make_regression(random_state=561)
        df = pd.DataFrame(x)
        df['y'] = y

        m = ElasticNet(n_splits=3, random_state=123)
        m = m.fit(df.drop(['y'], axis=1), df.y)
        sanity_check_regression(m, x)
Beispiel #3
0
 def test_n_splits(self):
     x, y = self.inputs[0]
     for n in self.n_splits:
         m = ElasticNet(n_splits=n, random_state=6601)
         if n > 0 and n < 3:
             with self.assertRaisesRegexp(ValueError,
                                          "n_splits must be at least 3"):
                 m = m.fit(x, y)
         else:
             m = m.fit(x, y)
             sanity_check_regression(m, x)
Beispiel #4
0
    def test_with_defaults(self):
        m = ElasticNet(random_state=2821)
        for x, y in self.inputs:
            m = m.fit(x, y)
            sanity_check_regression(m, x)

            # check selection of lambda_best
            self.assertTrue(m.lambda_best_inx_ <= m.lambda_max_inx_)

            # check full path predict
            p = m.predict(x, lamb=m.lambda_path_)
            self.assertEqual(p.shape[-1], m.lambda_path_.size)