Esempio n. 1
0
def model(base, titanic_vd):
    base.cursor.execute("DROP MODEL IF EXISTS ohe_model_test")
    model_class = OneHotEncoder("ohe_model_test",
                                cursor=base.cursor,
                                drop_first=False)
    model_class.fit("public.titanic", ["pclass", "sex", "embarked"])
    yield model_class
    model_class.drop()
Esempio n. 2
0
 def test_model_from_vDF(self, titanic_vd):
     current_cursor().execute("DROP MODEL IF EXISTS ohe_vDF")
     model_test = OneHotEncoder("ohe_vDF", drop_first=False)
     model_test.fit(titanic_vd, ["pclass", "embarked"])
     current_cursor().execute(
         "SELECT model_name FROM models WHERE model_name = 'ohe_vDF'")
     assert current_cursor().fetchone()[0] == "ohe_vDF"
     model_test.drop()
Esempio n. 3
0
    def test_set_cursor(self, base):
        model_test = OneHotEncoder("ohe_cursor_test",
                                   cursor=base.cursor,
                                   drop_first=False)
        # TODO: creat a new cursor
        model_test.set_cursor(base.cursor)
        model_test.drop()
        model_test.fit("public.titanic", ["pclass"])

        base.cursor.execute(
            "SELECT model_name FROM models WHERE model_name = 'ohe_cursor_test'"
        )
        assert base.cursor.fetchone()[0] == "ohe_cursor_test"
        model_test.drop()
Esempio n. 4
0
    def test_drop(self, base):
        base.cursor.execute("DROP MODEL IF EXISTS ohe_model_test_drop")
        model_test = OneHotEncoder("ohe_model_test_drop", cursor=base.cursor)
        model_test.fit("public.titanic", ["pclass", "embarked"])

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

        model_test.drop()
        base.cursor.execute(
            "SELECT model_name FROM models WHERE model_name = 'ohe_model_test_drop'"
        )
        assert base.cursor.fetchone() is None
Esempio n. 5
0
    def test_drop(self):
        current_cursor().execute("DROP MODEL IF EXISTS ohe_model_test_drop")
        model_test = OneHotEncoder("ohe_model_test_drop", )
        model_test.fit("public.titanic", ["pclass", "embarked"])

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

        model_test.drop()
        current_cursor().execute(
            "SELECT model_name FROM models WHERE model_name = 'ohe_model_test_drop'"
        )
        assert current_cursor().fetchone() is None
 def test_repr(self, model):
     assert "one_hot_encoder_fit" in model.__repr__()
     model_repr = OneHotEncoder("model_repr")
     model_repr.drop()
     assert model_repr.__repr__() == "<OneHotEncoder>"
Esempio n. 7
0
def model(titanic_vd):
    model_class = OneHotEncoder("ohe_model_test", drop_first=False)
    model_class.drop()
    model_class.fit("public.titanic", ["pclass", "sex", "embarked"])
    yield model_class
    model_class.drop()