SAX Example 5: Multiple-Input Version - 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ā„¢

In the multiple-input version, the mean and standard deviation statistics are applied globally with meanstats and the stdevstats tables, respectively.

Input

SQL Call

The statistics are created from a query on the input table finance_data3 and grouped by column id.

SELECT * FROM SAX (
  ON finance_data3 AS "input" PARTITION BY id ORDER BY id 
  ON (SELECT id, AVG (expenditure) AS expenditure,
        AVG (income) AS income,
        AVG (investment) AS investment
      FROM finance_data3 GROUP BY id
     ) AS meanstats PARTITION BY id
  ON (SELECT id, STDDEV_SAMP (expenditure) AS expenditure,
        STDDEV_SAMP (income) AS income,
        STDDEV_SAMP (investment) AS investment
      FROM finance_data3 GROUP BY id
     ) AS stdevstats PARTITION BY id
  USING
  TargetColumns ('expenditure', 'income', 'investment')
  TimeColumn ('period')
  WindowType ('global')
  OutputStats ('true')
  Accumulate ('id')
) AS dt ORDER BY id;

Output

id period_start period_end expenditure_saxcode expenditure_mean expenditure_stdev income_saxcode income_mean income_stdev investment_saxcode investment_mean investment_stdev
1 1960Q1 1969Q4 61616161626262626262626262626262626262626262626262626262626262636363636364646464 714.2 385.0403375472 61616161626262626262626262626262626262626262626262626262626262636363636364646464 811.2 449.682520486142 61616161616161626262626261626262626262626263636363636363626262636262636364646464 301 130.70871903117
2 1970Q1 1979Q4 64646464646464646161616161616161616161616262626262626262626262636363636363636364 1355.6 404.842280147308 64646464646464646161616161616161616161616262626262626262626263636363636363636363 1589.275 470.779059045639 64646464646464646161616161616161626262626262626263626262636262626262626262636363 556.675 142.199821035626
3 1980Q1 1982Q4 616161616363636464646464 2045.16666666667 256.612489362793 616161616363636464646464 2387.41666666667 317.496587908175 616161616364646363636363 759.083333333333 113.352594174375