GLM2 Example 3: Elastic Net for Gaussian Regression Analysis - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
8.00
1.0
Published
May 2019
Language
English (United States)
Last Update
2019-11-22
dita:mapPath
blj1506016597986.ditamap
dita:ditavalPath
blj1506016597986.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

This example uses elastic net, a combination of the ridge and LASSO methods.

Input

The input table, glm2_elastic_net, contains a set of U. S. macroeconomic variables for the years 1947 through 1962. The response variable is the number of people employed (in millions).

glm2_elastic_net
id gnp_deflator gnp unemployed armed_forces population year employed
1 83 234.289 235.6 159 107.608 1947 60.323
2 88.5 259.426 232.5 145.6 108.632 1948 61.122
3 88.2 258.054 368.2 161.6 109.773 1949 60.171
4 89.5 284.599 335.1 165 110.929 1950 61.187
5 96.2 328.975 209.9 309.9 112.075 1951 63.221
6 98.1 346.999 193.2 359.4 113.27 1952 63.639
7 99 365.385 187 354.7 115.094 1953 64.989
8 100 363.112 357.8 335 116.219 1954 63.761
9 101.2 397.469 290.4 304.8 117.388 1955 66.019
10 104.6 419.18 282.2 285.7 118.734 1956 67.857
11 108.4 442.769 293.6 279.8 120.445 1957 68.169
12 110.8 444.546 468.1 263.7 121.95 1958 66.513
13 112.6 482.704 381.3 255.2 123.366 1959 68.655
14 114.2 502.601 393.1 251.4 125.368 1960 69.564
15 115.7 518.173 480.6 257.2 127.852 1961 69.331
16 116.9 554.894 400.7 282.7 130.081 1962 70.551

SQL Call

Because the response variable has a normal distribution, the Family is Gaussian. The Alpha value, 0.1, specifies an elastic net model.

SELECT * FROM GLM2 (
  ON glm2_elastic_net AS InputTable
  OUT TABLE ModelTable (glm2_elastic_net_model)
  OUT TABLE RegularizationTable (glm2_3regularization)
  USING
  InputColumns ('gnp_deflator','gnp','armed_forces','population')
  ResponseColumn ('employed')
  Family ('GAUSSIAN')
  Intercept ('TRUE')
  NumLambdas (10)
  Alpha (0.1)
) AS dt;

Output

Onscreen Output
dfDevRatio devRatio dfDev deviance lambda
0 0 15 185.008826 33.4451683575075
3 0.495555028370924 12 93.3267719826986 12.0195703031457
4 0.825255933667388 11 32.3291945626626 4.31960959885052
4 0.930305894169471 11 12.8940246988259 1.55238719986506
4 0.951974575788374 11 8.88512735154485 0.557899033039046
4 0.957608388774071 11 7.84282222515759 0.200498516795911
4 0.963457573112318 11 6.76067149768095 0.0720554309233708
4 0.971089487544852 11 5.34869996838526 0.0258953792203741
4 0.980005044362085 11 3.69924326849269 0.00930631676715827
4 0.984687706599481 11 2.83290942539757 0.00334451683575075
glm2_3regularization
df_dev_ratio deviance_ratio df_dev deviance lambda intercept armed_forces gnp gnp_deflator population
0 0 15 185.008826 33.4451683575075 65.317 0 0 0 0
3 0.495555028370924 12 93.3267719826986 12.0195703031457 54.8218575447 0 0.0036713396 0.0326415425 0.0489911516
4 0.825255933667388 11 32.3291945626626 4.31960959885052 43.8369917073 0.0017090903 0.0074174574 0.0652234077 0.0981636428
4 0.930305894169471 11 12.8940246988259 1.55238719986506 37.154679985 0.0024827573 0.0101765417 0.0856518657 0.126554407
4 0.951974575788374 11 8.88512735154485 0.557899033039046 35.1825736622 0.0024452942 0.0125438456 0.093815729 0.1285468441
4 0.957608388774071 11 7.84282222515759 0.200498516795911 37.4679867235 0.0020860735 0.0163287498 0.0905074779 0.1002494791
4 0.963457573112318 11 6.76067149768095 0.0720554309233708 45.5465937467 0.0013152824 0.0244413997 0.0730722137 0.0214742023
4 0.971089487544852 11 5.34869996838526 0.0258953792203741 58.8296374248 0.0002910015 0.0379400515 0.0279059919 -0.0948299091
4 0.980005044362085 11 3.69924326849269 0.00930631676715827 81.0307817472 -0.0015741337 0.0585698986 -0.0217865608 -0.3048408138
4 0.984687706599481 11 2.83290942539757 0.00334451683575075 100.3707843847 -0.0030991548 0.0773443707 -0.0790919789 -0.4785227208

The function also outputs a model table, which is not shown here.