CrossValidation2 Example: Regression Models | Teradata Vantage - CrossValidation2 Example: Regression Models - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
9.02
9.01
2.0
1.3
Published
February 2022
Language
English (United States)
Last Update
2022-02-10
dita:mapPath
rnn1580259159235.ditamap
dita:ditavalPath
ybt1582220416951.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

This example calculates the cross-validation error for models trained by the GLML1L2 function by regression (the GLML1L2 call specified Family ('GAUSSIAN')) and shows the training error for each fold in the output table.

Input

The input table, admissions_train, is from GLM Example: Logistic Regression Analysis with Intercept.

SQL Call

SELECT * FROM CrossValidation2 (
  ON admissions_train AS InputTable
  OUT TABLE OutputTable (cv_out)
  USING
  FunctionName ('GLML1L2')
  Metric ('mse')
  EvaluateTraining ('t')
  IdColumn ('id')
  TargetColumns ('masters', 'gpa', 'stats', 'programming')
  CategoricalColumns ('masters', 'stats', 'programming')
  ResponseColumn ('admitted')
  Family ('Gaussian')
  Alpha (0)
  RegularizationLambda (0.02)
) AS dt;

Output

   fold_num    |  validation_mse   |   training_mse    
---------------+-------------------+-------------------
 best_score    | 0.225835152720764 |  0.15986538159187
 average_score | 0.265838722846472 |  0.153415214510181
 1             | 0.270134841041979 |  0.149599142261067
 2             | 0.278042443533549 |  0.144148161584926
 3             | 0.254015424730324 |  0.163766866292805
 4             | 0.225835152720764 |  0.15986538159187
 5             | 0.301165752205742 |  0.149696520820234
SELECT * FROM cv_out;
   attribute    | category |      estimate      | information
----------------+----------+--------------------+-------------
 (Intercept)    |          |  0.614277761352143 | p
 masters        | yes      | -0.377583967343473 | p
 stats          | beginner |  0.198291660224301 | p
 stats          | novice   |  0.132269305463436 | p
 programming    | beginner | -0.443020944585588 | p
 programming    | novice   | -0.204447536127055 | p
 gpa            |          | 0.0873461023294575 | p
 Family         |          |                    | Gaussian
 Regularization |          |                    | Ridge
 Alpha          |          |                  0 |
 Lambda         |          |               0.02 |
 Iterations #   |          |                 16 |
 Converged      |          |                    | true
 Rows #         |          |                 32 |
 Features #     |          |                  7 |
 RMSE           |          |  0.409976691591614 |
 AIC            |          |   17.5666198827054 |
 BIC            |          |   27.8267712023035 |

Download a zip file of all examples and a SQL script file that creates their input tables.