示例#1
0
def model(winequality_vd):
    model_class = LinearSVR("lsvr_model_test", )
    model_class.drop()
    model_class.fit("public.winequality",
                    ["citric_acid", "residual_sugar", "alcohol"], "quality")
    yield model_class
    model_class.drop()
示例#2
0
def model(base, winequality_vd):
    base.cursor.execute("DROP MODEL IF EXISTS lsvr_model_test")
    model_class = LinearSVR("lsvr_model_test", cursor=base.cursor)
    model_class.fit("public.winequality",
                    ["citric_acid", "residual_sugar", "alcohol"], "quality")
    yield model_class
    model_class.drop()
示例#3
0
 def test_get_plot(self, winequality_vd):
     current_cursor().execute("DROP MODEL IF EXISTS model_test_plot")
     model_test = LinearSVR("model_test_plot", )
     model_test.fit("public.winequality", ["alcohol"], "quality")
     result = model_test.plot()
     assert len(result.get_default_bbox_extra_artists()) == 9
     plt.close("all")
     model_test.drop()
示例#4
0
    def test_model_from_vDF(self, base, winequality_vd):
        base.cursor.execute("DROP MODEL IF EXISTS lsvr_from_vDF")
        model_test = LinearSVR("lsvr_from_vDF", cursor=base.cursor)
        model_test.fit(winequality_vd, ["alcohol"], "quality")

        base.cursor.execute(
            "SELECT model_name FROM models WHERE model_name = 'lsvr_from_vDF'")
        assert base.cursor.fetchone()[0] == "lsvr_from_vDF"

        model_test.drop()
示例#5
0
 def test_contour(self, winequality_vd):
     model_test = LinearSVR("model_contour", )
     model_test.drop()
     model_test.fit(
         winequality_vd,
         ["citric_acid", "residual_sugar"],
         "quality",
     )
     result = model_test.contour()
     assert len(result.get_default_bbox_extra_artists()) == 38
     model_test.drop()
示例#6
0
    def test_set_cursor(self, base):
        model_test = LinearSVR("lsvr_cursor_test", cursor=base.cursor)
        # TODO: creat a new cursor
        model_test.set_cursor(base.cursor)
        model_test.drop()
        model_test.fit("public.winequality", ["alcohol"], "quality")

        base.cursor.execute(
            "SELECT model_name FROM models WHERE model_name = 'lsvr_cursor_test'"
        )
        assert base.cursor.fetchone()[0] == "lsvr_cursor_test"

        model_test.drop()
示例#7
0
    def test_drop(self, base):
        base.cursor.execute("DROP MODEL IF EXISTS lsvr_model_test_drop")
        model_test = LinearSVR("lsvr_model_test_drop", cursor=base.cursor)
        model_test.fit("public.winequality", ["alcohol"], "quality")

        base.cursor.execute(
            "SELECT model_name FROM models WHERE model_name = 'lsvr_model_test_drop'"
        )
        assert base.cursor.fetchone()[0] == "lsvr_model_test_drop"

        model_test.drop()
        base.cursor.execute(
            "SELECT model_name FROM models WHERE model_name = 'lsvr_model_test_drop'"
        )
        assert base.cursor.fetchone() is None
示例#8
0
    def test_drop(self):
        current_cursor().execute("DROP MODEL IF EXISTS lsvr_model_test_drop")
        model_test = LinearSVR("lsvr_model_test_drop", )
        model_test.fit("public.winequality", ["alcohol"], "quality")

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

        model_test.drop()
        current_cursor().execute(
            "SELECT model_name FROM models WHERE model_name = 'lsvr_model_test_drop'"
        )
        assert current_cursor().fetchone() is None