text: -- This SQL code was generated by sklearn2sql (development version).
  -- Copyright 2018
  
  -- Model : CaretClassifier_ctree2
  -- Dataset : FourClass_10
  -- Database : teradata
  
  
  -- This SQL code can contain one or more statements, to be executed in the order they appear in this file.
  
  
  
  -- Model deployment code
  
  WITH "DT_node_lookup" AS 
  (SELECT "ADS"."KEY" AS "KEY", CASE WHEN ("ADS"."Feature_3" <= CAST(-1.906348811364 AS DOUBLE PRECISION)) THEN 2 ELSE CASE WHEN ("ADS"."Feature_7" <= CAST(0.343057625083 AS DOUBLE PRECISION)) THEN CASE WHEN ("ADS"."Feature_4" <= CAST(-0.368741519445 AS DOUBLE PRECISION)) THEN 5 ELSE 6 END ELSE CASE WHEN ("ADS"."Feature_1" <= CAST(-0.133085777187 AS DOUBLE PRECISION)) THEN 8 ELSE 9 END END END AS node_id_2 
  FROM "FourClass_10" AS "ADS"), 
  dummy_cte AS 
  (SELECT CAST(0.0 AS DOUBLE PRECISION) AS "X"), 
  "DT_node_data" AS 
  (SELECT "Values".nid AS nid, "Values"."P_0" AS "P_0", "Values"."P_1" AS "P_1", "Values"."P_2" AS "P_2", "Values"."P_3" AS "P_3", "Values"."D" AS "D", "Values"."DP" AS "DP" 
  FROM (SELECT 2 AS nid, CAST(0.0 AS DOUBLE PRECISION) AS "P_0", CAST(0.0 AS DOUBLE PRECISION) AS "P_1", CAST(1.0 AS DOUBLE PRECISION) AS "P_2", CAST(0.0 AS DOUBLE PRECISION) AS "P_3", 2 AS "D", CAST(1.0 AS DOUBLE PRECISION) AS "DP" 
  FROM dummy_cte UNION ALL SELECT 5 AS nid, CAST(0.043478260869565 AS DOUBLE PRECISION) AS "P_0", CAST(0.0 AS DOUBLE PRECISION) AS "P_1", CAST(0.130434782608696 AS DOUBLE PRECISION) AS "P_2", CAST(0.826086956521739 AS DOUBLE PRECISION) AS "P_3", 3 AS "D", CAST(0.826086956521739 AS DOUBLE PRECISION) AS "DP" 
  FROM dummy_cte UNION ALL SELECT 6 AS nid, CAST(0.5 AS DOUBLE PRECISION) AS "P_0", CAST(0.375 AS DOUBLE PRECISION) AS "P_1", CAST(0.0 AS DOUBLE PRECISION) AS "P_2", CAST(0.125 AS DOUBLE PRECISION) AS "P_3", 0 AS "D", CAST(0.5 AS DOUBLE PRECISION) AS "DP" 
  FROM dummy_cte UNION ALL SELECT 8 AS nid, CAST(0.916666666666667 AS DOUBLE PRECISION) AS "P_0", CAST(0.083333333333333 AS DOUBLE PRECISION) AS "P_1", CAST(0.0 AS DOUBLE PRECISION) AS "P_2", CAST(0.0 AS DOUBLE PRECISION) AS "P_3", 0 AS "D", CAST(0.916666666666667 AS DOUBLE PRECISION) AS "DP" 
  FROM dummy_cte UNION ALL SELECT 9 AS nid, CAST(0.074074074074074 AS DOUBLE PRECISION) AS "P_0", CAST(0.592592592592593 AS DOUBLE PRECISION) AS "P_1", CAST(0.259259259259259 AS DOUBLE PRECISION) AS "P_2", CAST(0.074074074074074 AS DOUBLE PRECISION) AS "P_3", 1 AS "D", CAST(0.592592592592593 AS DOUBLE PRECISION) AS "DP" 
  FROM dummy_cte) AS "Values"), 
  "DT_Output" AS 
  (SELECT "DT_node_lookup"."KEY" AS "KEY", "DT_node_lookup".node_id_2 AS node_id_2, "DT_node_data".nid AS nid, "DT_node_data"."P_0" AS "P_0", "DT_node_data"."P_1" AS "P_1", "DT_node_data"."P_2" AS "P_2", "DT_node_data"."P_3" AS "P_3", "DT_node_data"."D" AS "D", "DT_node_data"."DP" AS "DP" 
  FROM "DT_node_lookup" LEFT OUTER JOIN "DT_node_data" ON "DT_node_lookup".node_id_2 = "DT_node_data".nid)
   SELECT "DT_Output"."KEY" AS "KEY", CAST(NULL AS DOUBLE PRECISION) AS "Score_0", CAST(NULL AS DOUBLE PRECISION) AS "Score_1", CAST(NULL AS DOUBLE PRECISION) AS "Score_2", CAST(NULL AS DOUBLE PRECISION) AS "Score_3", "DT_Output"."P_0" AS "Proba_0", "DT_Output"."P_1" AS "Proba_1", "DT_Output"."P_2" AS "Proba_2", "DT_Output"."P_3" AS "Proba_3", CASE WHEN ("DT_Output"."P_0" IS NULL OR "DT_Output"."P_0" > CAST(0.0 AS DOUBLE PRECISION)) THEN ln("DT_Output"."P_0") ELSE -1.79769313486231e+308 END AS "LogProba_0", CASE WHEN ("DT_Output"."P_1" IS NULL OR "DT_Output"."P_1" > CAST(0.0 AS DOUBLE PRECISION)) THEN ln("DT_Output"."P_1") ELSE -1.79769313486231e+308 END AS "LogProba_1", CASE WHEN ("DT_Output"."P_2" IS NULL OR "DT_Output"."P_2" > CAST(0.0 AS DOUBLE PRECISION)) THEN ln("DT_Output"."P_2") ELSE -1.79769313486231e+308 END AS "LogProba_2", CASE WHEN ("DT_Output"."P_3" IS NULL OR "DT_Output"."P_3" > CAST(0.0 AS DOUBLE PRECISION)) THEN ln("DT_Output"."P_3") ELSE -1.79769313486231e+308 END AS "LogProba_3", "DT_Output"."D" AS "Decision", "DT_Output"."DP" AS "DecisionProba" 
  FROM "DT_Output"