text: -- This SQL code was generated by sklearn2sql (development version).
  -- Copyright 2018
  
  -- Model : CaretClassifier_earth
  -- Dataset : iris_date_tgt
  -- Database : db2
  
  
  -- This SQL code can contain one or more statements, to be executed in the order they appear in this file.
  
  
  
  -- Model deployment code
  
  WITH earth_input AS 
  (SELECT "ADS"."KEY" AS "KEY", CAST("ADS"."Feature_0" AS DOUBLE) AS "Feature_0", CAST("ADS"."Feature_1" AS DOUBLE) AS "Feature_1", CAST("ADS"."Feature_2" AS DOUBLE) AS "Feature_2", CAST("ADS"."Feature_3" AS DOUBLE) AS "Feature_3" 
  FROM "IRIS_DATE_TGT" AS "ADS"), 
  earth_model_cte AS 
  (SELECT earth_input."KEY" AS "KEY", 41.41051746815792 * greatest(3.9 - earth_input."Feature_2", 0) + 1.0916742696901622 * greatest(earth_input."Feature_3" - 2.0, 0) + -0.6470962481520242 * greatest(earth_input."Feature_3" - 1.4, 0) + -0.6289207803667948 * greatest(earth_input."Feature_0" - 6.1, 0) + 4.62752589834204 * greatest(earth_input."Feature_2" - 5.1, 0) + -28.803998540862246 * greatest(earth_input."Feature_2" - 4.7, 0) + 24.996461690247845 * greatest(earth_input."Feature_2" - 3.3, 0) + -59.95228367656241 AS "Score_1789-07-14T00:00:00.000000000", -6.395207315469439 * greatest(3.9 - earth_input."Feature_2", 0) + -56.88781758741218 * greatest(earth_input."Feature_3" - 2.0, 0) + -11.33063537642153 * greatest(earth_input."Feature_3" - 1.4, 0) + 12.361305279700884 * greatest(earth_input."Feature_0" - 6.1, 0) + -105.45956843275327 * greatest(earth_input."Feature_2" - 5.1, 0) + -16.63921624937212 * greatest(earth_input."Feature_2" - 4.7, 0) + -2.6226964767417966 * greatest(earth_input."Feature_2" - 3.3, 0) + 8.10905581702345 AS "Score_1789-08-14T00:00:00.000000000", -144.96926576249902 * greatest(3.9 - earth_input."Feature_2", 0) + 56.55496348523766 * greatest(earth_input."Feature_3" - 2.0, 0) + 14.161242582484396 * greatest(earth_input."Feature_3" - 1.4, 0) + -13.014628435253607 * greatest(earth_input."Feature_0" - 6.1, 0) + 105.38632644998407 * greatest(earth_input."Feature_2" - 5.1, 0) + 27.112019529507016 * greatest(earth_input."Feature_2" - 4.7, 0) + -3.1134722516891964 * greatest(earth_input."Feature_2" - 3.3, 0) + -1.894913056077661 AS "Score_1789-09-14T00:00:00.000000000" 
  FROM earth_input), 
  earth_model_cte_logistic AS 
  (SELECT earth_model_cte."KEY" AS "KEY", earth_model_cte."Score_1789-07-14T00:00:00.000000000" AS "Score_1789-07-14T00:00:00.000000000", 1.0 / (1.0 + exp(least(100.0, greatest(-100.0, -earth_model_cte."Score_1789-07-14T00:00:00.000000000")))) AS "Logistic_1789-07-14T00:00:00.000000000", earth_model_cte."Score_1789-08-14T00:00:00.000000000" AS "Score_1789-08-14T00:00:00.000000000", 1.0 / (1.0 + exp(least(100.0, greatest(-100.0, -earth_model_cte."Score_1789-08-14T00:00:00.000000000")))) AS "Logistic_1789-08-14T00:00:00.000000000", earth_model_cte."Score_1789-09-14T00:00:00.000000000" AS "Score_1789-09-14T00:00:00.000000000", 1.0 / (1.0 + exp(least(100.0, greatest(-100.0, -earth_model_cte."Score_1789-09-14T00:00:00.000000000")))) AS "Logistic_1789-09-14T00:00:00.000000000" 
  FROM earth_model_cte), 
  orig_cte AS 
  (SELECT earth_model_cte_logistic."KEY" AS "KEY", earth_model_cte_logistic."Score_1789-07-14T00:00:00.000000000" AS "Score_1789-07-14T00:00:00.000000000", earth_model_cte_logistic."Score_1789-08-14T00:00:00.000000000" AS "Score_1789-08-14T00:00:00.000000000", earth_model_cte_logistic."Score_1789-09-14T00:00:00.000000000" AS "Score_1789-09-14T00:00:00.000000000", earth_model_cte_logistic."Logistic_1789-07-14T00:00:00.000000000" / (earth_model_cte_logistic."Logistic_1789-07-14T00:00:00.000000000" + earth_model_cte_logistic."Logistic_1789-08-14T00:00:00.000000000" + earth_model_cte_logistic."Logistic_1789-09-14T00:00:00.000000000") AS "Proba_1789-07-14T00:00:00.000000000", earth_model_cte_logistic."Logistic_1789-08-14T00:00:00.000000000" / (earth_model_cte_logistic."Logistic_1789-07-14T00:00:00.000000000" + earth_model_cte_logistic."Logistic_1789-08-14T00:00:00.000000000" + earth_model_cte_logistic."Logistic_1789-09-14T00:00:00.000000000") AS "Proba_1789-08-14T00:00:00.000000000", earth_model_cte_logistic."Logistic_1789-09-14T00:00:00.000000000" / (earth_model_cte_logistic."Logistic_1789-07-14T00:00:00.000000000" + earth_model_cte_logistic."Logistic_1789-08-14T00:00:00.000000000" + earth_model_cte_logistic."Logistic_1789-09-14T00:00:00.000000000") AS "Proba_1789-09-14T00:00:00.000000000", CAST(NULL AS DOUBLE) AS "LogProba_1789-07-14T00:00:00.000000000", CAST(NULL AS DOUBLE) AS "LogProba_1789-08-14T00:00:00.000000000", CAST(NULL AS DOUBLE) AS "LogProba_1789-09-14T00:00:00.000000000", NULL AS "Decision", CAST(NULL AS DOUBLE) AS "DecisionProba" 
  FROM earth_model_cte_logistic), 
  score_class_union AS 
  (SELECT scu."KEY_u" AS "KEY_u", scu.class AS class, scu."LogProba" AS "LogProba", scu."Proba" AS "Proba", scu."Score" AS "Score" 
  FROM (SELECT orig_cte."KEY" AS "KEY_u", '1789-07-14T00:00:00.000000000' AS class, orig_cte."LogProba_1789-07-14T00:00:00.000000000" AS "LogProba", orig_cte."Proba_1789-07-14T00:00:00.000000000" AS "Proba", orig_cte."Score_1789-07-14T00:00:00.000000000" AS "Score" 
  FROM orig_cte UNION ALL SELECT orig_cte."KEY" AS "KEY_u", '1789-08-14T00:00:00.000000000' AS class, orig_cte."LogProba_1789-08-14T00:00:00.000000000" AS "LogProba", orig_cte."Proba_1789-08-14T00:00:00.000000000" AS "Proba", orig_cte."Score_1789-08-14T00:00:00.000000000" AS "Score" 
  FROM orig_cte UNION ALL SELECT orig_cte."KEY" AS "KEY_u", '1789-09-14T00:00:00.000000000' AS class, orig_cte."LogProba_1789-09-14T00:00:00.000000000" AS "LogProba", orig_cte."Proba_1789-09-14T00:00:00.000000000" AS "Proba", orig_cte."Score_1789-09-14T00:00:00.000000000" AS "Score" 
  FROM orig_cte) AS scu), 
  score_max AS 
  (SELECT orig_cte."KEY" AS "KEY", orig_cte."Score_1789-07-14T00:00:00.000000000" AS "Score_1789-07-14T00:00:00.000000000", orig_cte."Score_1789-08-14T00:00:00.000000000" AS "Score_1789-08-14T00:00:00.000000000", orig_cte."Score_1789-09-14T00:00:00.000000000" AS "Score_1789-09-14T00:00:00.000000000", orig_cte."Proba_1789-07-14T00:00:00.000000000" AS "Proba_1789-07-14T00:00:00.000000000", orig_cte."Proba_1789-08-14T00:00:00.000000000" AS "Proba_1789-08-14T00:00:00.000000000", orig_cte."Proba_1789-09-14T00:00:00.000000000" AS "Proba_1789-09-14T00:00:00.000000000", orig_cte."LogProba_1789-07-14T00:00:00.000000000" AS "LogProba_1789-07-14T00:00:00.000000000", orig_cte."LogProba_1789-08-14T00:00:00.000000000" AS "LogProba_1789-08-14T00:00:00.000000000", orig_cte."LogProba_1789-09-14T00:00:00.000000000" AS "LogProba_1789-09-14T00:00:00.000000000", orig_cte."Decision" AS "Decision", orig_cte."DecisionProba" AS "DecisionProba", max_select."KEY_m" AS "KEY_m", max_select."max_Proba" AS "max_Proba" 
  FROM orig_cte LEFT OUTER JOIN (SELECT score_class_union."KEY_u" AS "KEY_m", max(score_class_union."Proba") AS "max_Proba" 
  FROM score_class_union GROUP BY score_class_union."KEY_u") AS max_select ON orig_cte."KEY" = max_select."KEY_m"), 
  union_with_max AS 
  (SELECT score_class_union."KEY_u" AS "KEY_u", score_class_union.class AS class, score_class_union."LogProba" AS "LogProba", score_class_union."Proba" AS "Proba", score_class_union."Score" AS "Score", score_max."KEY" AS "KEY", score_max."Score_1789-07-14T00:00:00.000000000" AS "Score_1789-07-14T00:00:00.000000000", score_max."Score_1789-08-14T00:00:00.000000000" AS "Score_1789-08-14T00:00:00.000000000", score_max."Score_1789-09-14T00:00:00.000000000" AS "Score_1789-09-14T00:00:00.000000000", score_max."Proba_1789-07-14T00:00:00.000000000" AS "Proba_1789-07-14T00:00:00.000000000", score_max."Proba_1789-08-14T00:00:00.000000000" AS "Proba_1789-08-14T00:00:00.000000000", score_max."Proba_1789-09-14T00:00:00.000000000" AS "Proba_1789-09-14T00:00:00.000000000", score_max."LogProba_1789-07-14T00:00:00.000000000" AS "LogProba_1789-07-14T00:00:00.000000000", score_max."LogProba_1789-08-14T00:00:00.000000000" AS "LogProba_1789-08-14T00:00:00.000000000", score_max."LogProba_1789-09-14T00:00:00.000000000" AS "LogProba_1789-09-14T00:00:00.000000000", score_max."Decision" AS "Decision", score_max."DecisionProba" AS "DecisionProba", score_max."KEY_m" AS "KEY_m", score_max."max_Proba" AS "max_Proba" 
  FROM score_class_union LEFT OUTER JOIN score_max ON score_class_union."KEY_u" = score_max."KEY"), 
  arg_max_cte AS 
  (SELECT score_max."KEY" AS "KEY", score_max."Score_1789-07-14T00:00:00.000000000" AS "Score_1789-07-14T00:00:00.000000000", score_max."Score_1789-08-14T00:00:00.000000000" AS "Score_1789-08-14T00:00:00.000000000", score_max."Score_1789-09-14T00:00:00.000000000" AS "Score_1789-09-14T00:00:00.000000000", score_max."Proba_1789-07-14T00:00:00.000000000" AS "Proba_1789-07-14T00:00:00.000000000", score_max."Proba_1789-08-14T00:00:00.000000000" AS "Proba_1789-08-14T00:00:00.000000000", score_max."Proba_1789-09-14T00:00:00.000000000" AS "Proba_1789-09-14T00:00:00.000000000", score_max."LogProba_1789-07-14T00:00:00.000000000" AS "LogProba_1789-07-14T00:00:00.000000000", score_max."LogProba_1789-08-14T00:00:00.000000000" AS "LogProba_1789-08-14T00:00:00.000000000", score_max."LogProba_1789-09-14T00:00:00.000000000" AS "LogProba_1789-09-14T00:00:00.000000000", score_max."Decision" AS "Decision", score_max."DecisionProba" AS "DecisionProba", score_max."KEY_m" AS "KEY_m", score_max."max_Proba" AS "max_Proba", "arg_max_t_Proba"."KEY_Proba" AS "KEY_Proba", "arg_max_t_Proba"."arg_max_Proba" AS "arg_max_Proba" 
  FROM score_max LEFT OUTER JOIN (SELECT union_with_max."KEY" AS "KEY_Proba", max(union_with_max.class) AS "arg_max_Proba" 
  FROM union_with_max 
  WHERE union_with_max."max_Proba" <= union_with_max."Proba" GROUP BY union_with_max."KEY") AS "arg_max_t_Proba" ON score_max."KEY" = "arg_max_t_Proba"."KEY_Proba")
   SELECT arg_max_cte."KEY" AS "KEY", CAST(NULL AS DOUBLE) AS "Score_1789-07-14T00:00:00.000000000", CAST(NULL AS DOUBLE) AS "Score_1789-08-14T00:00:00.000000000", CAST(NULL AS DOUBLE) AS "Score_1789-09-14T00:00:00.000000000", arg_max_cte."Proba_1789-07-14T00:00:00.000000000" AS "Proba_1789-07-14T00:00:00.000000000", arg_max_cte."Proba_1789-08-14T00:00:00.000000000" AS "Proba_1789-08-14T00:00:00.000000000", arg_max_cte."Proba_1789-09-14T00:00:00.000000000" AS "Proba_1789-09-14T00:00:00.000000000", CASE WHEN (arg_max_cte."Proba_1789-07-14T00:00:00.000000000" IS NULL OR arg_max_cte."Proba_1789-07-14T00:00:00.000000000" > 0.0) THEN ln(arg_max_cte."Proba_1789-07-14T00:00:00.000000000") ELSE -1.79769313486231e+308 END AS "LogProba_1789-07-14T00:00:00.000000000", CASE WHEN (arg_max_cte."Proba_1789-08-14T00:00:00.000000000" IS NULL OR arg_max_cte."Proba_1789-08-14T00:00:00.000000000" > 0.0) THEN ln(arg_max_cte."Proba_1789-08-14T00:00:00.000000000") ELSE -1.79769313486231e+308 END AS "LogProba_1789-08-14T00:00:00.000000000", CASE WHEN (arg_max_cte."Proba_1789-09-14T00:00:00.000000000" IS NULL OR arg_max_cte."Proba_1789-09-14T00:00:00.000000000" > 0.0) THEN ln(arg_max_cte."Proba_1789-09-14T00:00:00.000000000") ELSE -1.79769313486231e+308 END AS "LogProba_1789-09-14T00:00:00.000000000", arg_max_cte."arg_max_Proba" AS "Decision", arg_max_cte."max_Proba" AS "DecisionProba" 
  FROM arg_max_cte