def model(titanic_vd): create_verticapy_schema() model_class = KernelDensity("KernelDensity_model_test",) model_class.drop() model_class.fit("public.titanic", ["age", "fare"]) yield model_class model_class.drop()
def test_model_from_vDF(self, titanic_vd): model_test = KernelDensity("KernelDensity_from_vDF_tmp",) model_test.drop() model_test.fit(titanic_vd, ["age", "fare"]) titanic_copy = model_test.predict(titanic_vd.copy(), name="kde") assert titanic_copy["kde"].mean() == pytest.approx( 1.82115211838814e-06, abs=1e-6 ) model_test.drop()
def test_get_plot(self, model): result = model.plot() assert len(result.get_default_bbox_extra_artists()) == 8 plt.close("all") model_test = KernelDensity("model_test_plot_kde_plot") model_test.drop() model_test.fit("public.titanic", ["age"]) result = model_test.plot() assert len(result.get_default_bbox_extra_artists()) == 9 model_test.drop()
def model(base, titanic_vd): try: create_verticapy_schema(base.cursor) except: pass model_class = KernelDensity("KernelDensity_model_test", cursor=base.cursor) model_class.drop() model_class.fit( "public.titanic", [ "age", "fare", ], ) yield model_class model_class.drop()
def test_model_from_vDF(self, base, titanic_vd): model_test = KernelDensity("KernelDensity_from_vDF_tmp", cursor=base.cursor) model_test.drop() model_test.fit( titanic_vd, [ "age", "fare", ], ) titanic_copy = model_test.predict(titanic_vd.copy(), name="kde") assert titanic_copy["kde"].mean() == pytest.approx( 6.52177350119195e-07, abs=1e-6) model_test.drop()
def test_drop(self, base): model_test = KernelDensity("model_test_drop", cursor=base.cursor) model_test.drop() model_test.fit( "public.titanic", [ "age", "fare", ], ) base.cursor.execute( "SELECT model_name FROM verticapy.models WHERE model_name IN ('model_test_drop', '\"model_test_drop\"')" ) assert base.cursor.fetchone()[0] in ('model_test_drop', '"model_test_drop"') model_test.drop() base.cursor.execute( "SELECT model_name FROM verticapy.models WHERE model_name IN ('model_test_drop', '\"model_test_drop\"')" ) assert base.cursor.fetchone() is None
def test_drop(self): model_test = KernelDensity("model_test_drop",) model_test.drop() model_test.fit("public.titanic", ["age", "fare"]) current_cursor().execute( """SELECT model_name FROM verticapy.models WHERE model_name IN ('model_test_drop', '\"model_test_drop\"')""" ) assert current_cursor().fetchone()[0] in ( "model_test_drop", '"model_test_drop"', ) model_test.drop() current_cursor().execute( """SELECT model_name FROM verticapy.models WHERE model_name IN ('model_test_drop', '\"model_test_drop\"')""" ) assert current_cursor().fetchone() is None
def test_repr(self, model): assert "Additional Info" in model.__repr__() model_repr = KernelDensity("model_repr", model.cursor) model_repr.drop() assert model_repr.__repr__() == "<KernelDensity>"