Beispiel #1
0
 def test_get_plot(self, winequality_vd):
     current_cursor().execute("DROP MODEL IF EXISTS model_test_plot")
     model_test = XGBoostRegressor("model_test_plot", )
     model_test.fit(winequality_vd, ["alcohol"], "quality")
     result = model_test.plot()
     assert len(result.get_default_bbox_extra_artists()) in (9, 12)
     plt.close("all")
     model_test.drop()
 def test_get_plot(self, base, winequality_vd):
     base.cursor.execute("DROP MODEL IF EXISTS model_test_plot")
     model_test = XGBoostRegressor("model_test_plot", cursor=base.cursor)
     model_test.fit(winequality_vd, ["alcohol"], "quality")
     result = model_test.plot()
     assert len(result.get_default_bbox_extra_artists()) == 9
     plt.close("all")
     model_test.drop()
Beispiel #3
0
    def test_model_from_vDF(self, xgbr_data_vd):
        current_cursor().execute("DROP MODEL IF EXISTS xgbr_from_vDF")
        model_test = XGBoostRegressor("xgbr_from_vDF", )
        model_test.fit(xgbr_data_vd, ["gender"], "transportation")

        current_cursor().execute(
            "SELECT model_name FROM models WHERE model_name = 'xgbr_from_vDF'")
        assert current_cursor().fetchone()[0] == "xgbr_from_vDF"

        model_test.drop()
Beispiel #4
0
 def test_contour(self, titanic_vd):
     model_test = XGBoostRegressor("model_contour", )
     model_test.drop()
     model_test.fit(
         titanic_vd,
         ["age", "fare"],
         "survived",
     )
     result = model_test.contour()
     assert len(result.get_default_bbox_extra_artists()) in (37, 34)
     model_test.drop()
 def test_contour(self, base, titanic_vd):
     model_test = XGBoostRegressor("model_contour", cursor=base.cursor)
     model_test.drop()
     model_test.fit(
         titanic_vd,
         [
             "age",
             "fare",
         ],
         "survived",
     )
     result = model_test.contour()
     assert len(result.get_default_bbox_extra_artists()) == 34
     model_test.drop()
Beispiel #6
0
    def test_drop(self):
        current_cursor().execute("DROP MODEL IF EXISTS xgbr_model_test_drop")
        model_test = XGBoostRegressor("xgbr_model_test_drop", )
        model_test.fit(
            "public.xgbr_data",
            ['"Gender"', '"owned cars"', '"cost"', '"income"'],
            "TransPortation",
        )

        current_cursor().execute(
            "SELECT model_name FROM models WHERE model_name = 'xgbr_model_test_drop'"
        )
        assert current_cursor().fetchone()[0] == "xgbr_model_test_drop"

        model_test.drop()
        current_cursor().execute(
            "SELECT model_name FROM models WHERE model_name = 'xgbr_model_test_drop'"
        )
        assert current_cursor().fetchone() is None
Beispiel #7
0
 def test_to_json(self, titanic_vd):
     titanic = titanic_vd.copy()
     titanic.fillna()
     path = "verticapy_test_xgbr.json"
     X = ["pclass", "age", "survived"]
     y = "fare"
     model = XGBoostRegressor("verticapy_xgb_regressor_test",
                              max_ntree=10,
                              max_depth=5)
     model.drop()
     model.fit(titanic, X, y)
     X_test = titanic[X].to_numpy()
     y_test_vertica = model.to_python()(X_test)
     if os.path.exists(path):
         os.remove(path)
     model.to_json(path)
     model_python = xgb.XGBRegressor()
     model_python.load_model(path)
     y_test_python = model_python.predict(X_test)
     result = (y_test_vertica - y_test_python)**2
     result = result.sum() / len(result)
     assert result == pytest.approx(0.0, abs=1.0e-11)
     model.drop()
     os.remove(path)