Exemple #1
0
 def test_to_sql(self, model, titanic_vd):
     model_test = DecisionTreeClassifier("rfc_sql_test")
     model_test.drop()
     model_test.fit(titanic_vd, ["age", "fare", "sex"], "survived")
     current_cursor().execute(
         "SELECT PREDICT_RF_CLASSIFIER(* USING PARAMETERS model_name = 'rfc_sql_test', match_by_pos=True)::int, {}::int FROM (SELECT 30.0 AS age, 45.0 AS fare, 'male' AS sex) x"
         .format(model_test.to_sql()))
     prediction = current_cursor().fetchone()
     assert prediction[0] == prediction[1]
     model_test.drop()
 def test_to_sql(self, model, titanic_vd):
     model_test = DecisionTreeClassifier("rfc_sql_test", cursor=model.cursor)
     model_test.drop()
     model_test.fit(titanic_vd, ["age", "fare", "sex"], "survived")
     model.cursor.execute(
         "SELECT PREDICT_RF_CLASSIFIER(* USING PARAMETERS model_name = 'rfc_sql_test', match_by_pos=True, class=1, type='probability')::float, {}::float FROM (SELECT 30.0 AS age, 45.0 AS fare, 'male' AS sex) x".format(
             model_test.to_sql()
         )
     )
     prediction = model.cursor.fetchone()
     assert prediction[0] == pytest.approx(prediction[1], 1e-2)
     model_test.drop()