text: -- This SQL code was generated by sklearn2sql (development version).
  -- Copyright 2018
  
  -- Model : CaretClassifier_rpart_pca
  -- Dataset : BinaryClass_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 "ADS_sca_1_OUT" AS 
  (SELECT "ADS"."KEY" AS "KEY", (CAST("ADS"."Feature_0" AS DOUBLE PRECISION) - CAST(0.061829205238135 AS DOUBLE PRECISION)) / CAST(1.236134089597546 AS DOUBLE PRECISION) AS "Feature_0", (CAST("ADS"."Feature_1" AS DOUBLE PRECISION) - CAST(0.177024637671833 AS DOUBLE PRECISION)) / CAST(0.946757498519011 AS DOUBLE PRECISION) AS "Feature_1", (CAST("ADS"."Feature_2" AS DOUBLE PRECISION) - CAST(0.041383850049034 AS DOUBLE PRECISION)) / CAST(1.080959732698354 AS DOUBLE PRECISION) AS "Feature_2", (CAST("ADS"."Feature_3" AS DOUBLE PRECISION) - CAST(0.130606468058471 AS DOUBLE PRECISION)) / CAST(1.086033510624102 AS DOUBLE PRECISION) AS "Feature_3", (CAST("ADS"."Feature_4" AS DOUBLE PRECISION) - CAST(-0.059558104719831 AS DOUBLE PRECISION)) / CAST(1.116589750763382 AS DOUBLE PRECISION) AS "Feature_4", (CAST("ADS"."Feature_5" AS DOUBLE PRECISION) - CAST(-0.048929089870106 AS DOUBLE PRECISION)) / CAST(1.386882454724367 AS DOUBLE PRECISION) AS "Feature_5", (CAST("ADS"."Feature_6" AS DOUBLE PRECISION) - CAST(0.191017978617131 AS DOUBLE PRECISION)) / CAST(0.979670721363872 AS DOUBLE PRECISION) AS "Feature_6", (CAST("ADS"."Feature_7" AS DOUBLE PRECISION) - CAST(0.022049596732675 AS DOUBLE PRECISION)) / CAST(0.477597382512509 AS DOUBLE PRECISION) AS "Feature_7", (CAST("ADS"."Feature_8" AS DOUBLE PRECISION) - CAST(-0.05772981403414 AS DOUBLE PRECISION)) / CAST(1.071324358190733 AS DOUBLE PRECISION) AS "Feature_8", (CAST("ADS"."Feature_9" AS DOUBLE PRECISION) - CAST(-0.052549592052032 AS DOUBLE PRECISION)) / CAST(1.232258725853038 AS DOUBLE PRECISION) AS "Feature_9" 
  FROM "BinaryClass_10" AS "ADS"), 
  "ADS_pre_1_OUT" AS 
  (SELECT "ADS_sca_1_OUT"."KEY" AS "KEY", "ADS_sca_1_OUT"."Feature_0" * CAST(0.566159232192036 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_1" * CAST(-0.035526328604153 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_2" * CAST(-0.046787936312051 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_3" * CAST(0.008946515209954 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_4" * CAST(0.082951188840366 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_5" * CAST(-0.102052212961004 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_6" * CAST(0.142445150790375 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_7" * CAST(0.566656668883156 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_8" * CAST(-0.066314277287908 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_9" * CAST(-0.559328985495082 AS DOUBLE PRECISION) AS "PC1", "ADS_sca_1_OUT"."Feature_0" * CAST(0.076712580027952 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_1" * CAST(-0.401537944583286 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_2" * CAST(0.567757825044682 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_3" * CAST(0.236973570301066 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_4" * CAST(-0.096329229162562 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_5" * CAST(-0.576778727916188 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_6" * CAST(-0.321637693479788 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_7" * CAST(-0.006693968243625 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_8" * CAST(-0.064211589452152 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_9" * CAST(0.069320080345438 AS DOUBLE PRECISION) AS "PC2", "ADS_sca_1_OUT"."Feature_0" * CAST(-0.044288079172689 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_1" * CAST(0.022442861422886 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_2" * CAST(-0.170938432317477 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_3" * CAST(0.418793802030975 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_4" * CAST(0.463880454713056 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_5" * CAST(0.124363843323912 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_6" * CAST(-0.249119763075 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_7" * CAST(-0.027070140621398 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_8" * CAST(-0.706606389230046 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_9" * CAST(0.013755282331336 AS DOUBLE PRECISION) AS "PC3", "ADS_sca_1_OUT"."Feature_0" * CAST(0.035505292609371 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_1" * CAST(0.462941597631812 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_2" * CAST(0.397039497281857 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_3" * CAST(0.108176435008563 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_4" * CAST(-0.54438802799142 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_5" * CAST(0.388699121446378 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_6" * CAST(-0.313627068551078 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_7" * CAST(0.09412147953131 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_8" * CAST(-0.204130331226492 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_9" * CAST(-0.136918343141165 AS DOUBLE PRECISION) AS "PC4", "ADS_sca_1_OUT"."Feature_0" * CAST(-0.023956113345304 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_1" * CAST(0.305966306740371 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_2" * CAST(0.124414861972722 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_3" * CAST(0.72052321304335 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_4" * CAST(-0.010360887714255 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_5" * CAST(-0.123138664673271 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_6" * CAST(0.563071125176879 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_7" * CAST(-0.042876365018652 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_8" * CAST(0.183916924199741 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_9" * CAST(0.056520588594193 AS DOUBLE PRECISION) AS "PC5", "ADS_sca_1_OUT"."Feature_0" * CAST(0.048169250614027 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_1" * CAST(0.623936249667701 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_2" * CAST(0.20083118524117 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_3" * CAST(-0.161860810639755 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_4" * CAST(0.543200733049669 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_5" * CAST(-0.243618603694409 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_6" * CAST(-0.314723330308694 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_7" * CAST(0.013375452116101 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_8" * CAST(0.296709034123596 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_9" * CAST(0.012969345295026 AS DOUBLE PRECISION) AS "PC6", "ADS_sca_1_OUT"."Feature_0" * CAST(-0.067735908634631 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_1" * CAST(-0.117581817738582 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_2" * CAST(0.647709549343604 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_3" * CAST(-0.311227282367873 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_4" * CAST(0.334776881812109 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_5" * CAST(0.294963754991101 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_6" * CAST(0.460736675610007 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_7" * CAST(-0.025868856528123 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_8" * CAST(-0.230508237026858 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_9" * CAST(-0.005964439285718 AS DOUBLE PRECISION) AS "PC7" 
  FROM "ADS_sca_1_OUT"), 
  "DT_node_lookup" AS 
  (SELECT "ADS_pre_1_OUT"."KEY" AS "KEY", CASE WHEN ("ADS_pre_1_OUT"."PC1" >= CAST(-0.658345867146726 AS DOUBLE PRECISION)) THEN CASE WHEN ("ADS_pre_1_OUT"."PC2" < CAST(0.315013132598996 AS DOUBLE PRECISION)) THEN 4 ELSE CASE WHEN ("ADS_pre_1_OUT"."PC1" >= CAST(1.374542423482741 AS DOUBLE PRECISION)) THEN 10 ELSE 11 END END ELSE 3 END AS node_id_2 
  FROM "ADS_pre_1_OUT"), 
  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"."D" AS "D", "Values"."DP" AS "DP" 
  FROM (SELECT 3 AS nid, CAST(0.0 AS DOUBLE PRECISION) AS "P_0", CAST(1.0 AS DOUBLE PRECISION) AS "P_1", 1 AS "D", CAST(1.0 AS DOUBLE PRECISION) AS "DP" 
  FROM dummy_cte UNION ALL SELECT 4 AS nid, CAST(0.88235294117647 AS DOUBLE PRECISION) AS "P_0", CAST(0.117647058823529 AS DOUBLE PRECISION) AS "P_1", 0 AS "D", CAST(0.88235294117647 AS DOUBLE PRECISION) AS "DP" 
  FROM dummy_cte UNION ALL SELECT 10 AS nid, CAST(0.875 AS DOUBLE PRECISION) AS "P_0", CAST(0.125 AS DOUBLE PRECISION) AS "P_1", 0 AS "D", CAST(0.875 AS DOUBLE PRECISION) AS "DP" 
  FROM dummy_cte UNION ALL SELECT 11 AS nid, CAST(0.230769230769231 AS DOUBLE PRECISION) AS "P_0", CAST(0.769230769230769 AS DOUBLE PRECISION) AS "P_1", 1 AS "D", CAST(0.769230769230769 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"."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", "DT_Output"."P_0" AS "Proba_0", "DT_Output"."P_1" AS "Proba_1", 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", "DT_Output"."D" AS "Decision", "DT_Output"."DP" AS "DecisionProba" 
  FROM "DT_Output"