def test_sklearn_tree1(self):
     from sklearn.tree import DecisionTreeRegressor
     X, y = iris_data()
     check_model_representation(DecisionTreeRegressor(max_depth=1),
                                X,
                                y,
                                verbose=False,
                                suffix="t1")
 def test_sklearn_tree2(self):
     from sklearn.tree import DecisionTreeRegressor
     X, y = iris_data()
     check_model_representation(model=DecisionTreeRegressor(max_depth=2),
                                X=X,
                                y=y,
                                verbose=True,
                                suffix="t2")
Пример #3
0
 def test_sklearn_scaler(self):
     from sklearn.preprocessing import StandardScaler
     data = numpy.array([[0, 0], [0, 0], [1, 1], [1, 1]],
                        dtype=numpy.float32)
     check_model_representation(StandardScaler, data, verbose=False)
     # The second compilation fails if suffix is not specified.
     check_model_representation(model=StandardScaler,
                                X=data,
                                verbose=False,
                                suffix="_2")
    def test_sklearn_linear_regression_verbose(self):
        from sklearn.linear_model import LinearRegression
        X, y = iris_data()
        rows = []

        def myprint(*args, **kwargs):
            rows.append(' '.join(map(str, args)))

        check_model_representation(
            LinearRegression, X, y, verbose=True, fLOG=myprint)
        self.assertGreater(len(rows), 2)
Пример #5
0
    def test_sklearn_linear_regression_verbose(self):
        X, y = iris_data()
        rows = []

        def myprint(*args, **kwargs):
            rows.append(' '.join(map(str, args)))

        check_model_representation(LinearRegression,
                                   X,
                                   y,
                                   verbose=True,
                                   fLOG=myprint,
                                   suffix='A')
        check_model_representation(LinearRegression,
                                   X.tolist(),
                                   y.tolist(),
                                   verbose=True,
                                   fLOG=myprint,
                                   suffix='B')
        self.assertGreater(len(rows), 2)
        xdf = pandas.DataFrame(X)
        try:
            check_model_representation(LinearRegression,
                                       xdf,
                                       y.tolist(),
                                       verbose=True,
                                       fLOG=myprint,
                                       suffix='B')
        except TypeError as e:
            self.assertIn("value is not a numpy.array but", str(e))
            return
        self.assertGreater(len(rows), 2)