text: -- This SQL code was generated by sklearn2sql (development version).
  -- Copyright 2018
  
  -- Model : CaretRegressor_earth_pca
  -- Dataset : freidman3
  -- 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(43.791281222074 AS DOUBLE PRECISION)) / CAST(26.1998878150635 AS DOUBLE PRECISION) AS "Feature_0", (CAST("ADS"."Feature_1" AS DOUBLE PRECISION) - CAST(945.96728330844 AS DOUBLE PRECISION)) / CAST(464.3666952541536 AS DOUBLE PRECISION) AS "Feature_1", (CAST("ADS"."Feature_2" AS DOUBLE PRECISION) - CAST(0.531000909997521 AS DOUBLE PRECISION)) / CAST(0.292017174945916 AS DOUBLE PRECISION) AS "Feature_2", (CAST("ADS"."Feature_3" AS DOUBLE PRECISION) - CAST(6.139967152050498 AS DOUBLE PRECISION)) / CAST(3.092304925382 AS DOUBLE PRECISION) AS "Feature_3" 
  FROM freidman3 AS "ADS"), 
  "ADS_pre_1_OUT" AS 
  (SELECT "ADS_sca_1_OUT"."KEY" AS "KEY", "ADS_sca_1_OUT"."Feature_0" * CAST(-0.61216507491007 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_1" * CAST(0.546478290332943 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_2" * CAST(-0.570867748564476 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_3" * CAST(-0.026933490380143 AS DOUBLE PRECISION) AS "PC1", "ADS_sca_1_OUT"."Feature_0" * CAST(0.488881338042008 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_1" * CAST(0.274519258456139 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_2" * CAST(-0.223844999535911 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_3" * CAST(-0.797199868435587 AS DOUBLE PRECISION) AS "PC2", "ADS_sca_1_OUT"."Feature_0" * CAST(-0.024686176636209 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_1" * CAST(0.709191857651851 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_2" * CAST(0.703881747208946 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_3" * CAST(0.031432271147406 AS DOUBLE PRECISION) AS "PC3", "ADS_sca_1_OUT"."Feature_0" * CAST(-0.620998833378688 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_1" * CAST(-0.350781362064452 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_2" * CAST(0.358544161544677 AS DOUBLE PRECISION) + "ADS_sca_1_OUT"."Feature_3" * CAST(-0.602294752752124 AS DOUBLE PRECISION) AS "PC4" 
  FROM "ADS_sca_1_OUT"), 
  earth_input AS 
  (SELECT "ADS_pre_1_OUT"."KEY" AS "KEY", CAST("ADS_pre_1_OUT"."PC1" AS DOUBLE PRECISION) AS "PC1", CAST("ADS_pre_1_OUT"."PC2" AS DOUBLE PRECISION) AS "PC2", CAST("ADS_pre_1_OUT"."PC3" AS DOUBLE PRECISION) AS "PC3", CAST("ADS_pre_1_OUT"."PC4" AS DOUBLE PRECISION) AS "PC4" 
  FROM "ADS_pre_1_OUT"), 
  earth_model_cte AS 
  (SELECT earth_input."KEY" AS "KEY", CAST(-0.8104395754511 AS DOUBLE PRECISION) * greatest(CAST(-1.132035998277834 AS DOUBLE PRECISION) - earth_input."PC3", CAST(0 AS DOUBLE PRECISION)) + CAST(0.177123802641706 AS DOUBLE PRECISION) * greatest(CAST(-0.584428464902442 AS DOUBLE PRECISION) - earth_input."PC2", CAST(0 AS DOUBLE PRECISION)) + CAST(-0.161864101297791 AS DOUBLE PRECISION) * greatest(CAST(0.473259075809929 AS DOUBLE PRECISION) - earth_input."PC1", CAST(0 AS DOUBLE PRECISION)) + CAST(-0.110302433097333 AS DOUBLE PRECISION) * greatest(earth_input."PC1" - CAST(-1.392960009774179 AS DOUBLE PRECISION), CAST(0 AS DOUBLE PRECISION)) + CAST(0.122764810826138 AS DOUBLE PRECISION) * greatest(earth_input."PC3" - CAST(-0.990318649514407 AS DOUBLE PRECISION), CAST(0 AS DOUBLE PRECISION)) + CAST(1.508249314352372 AS DOUBLE PRECISION) AS "Estimator" 
  FROM earth_input)
   SELECT earth_model_cte."KEY" AS "KEY", earth_model_cte."Estimator" AS "Estimator" 
  FROM earth_model_cte