1.1 - 8.10 - Scale Example: Multiple Methods - Teradata Vantage

Teradata Vantage™ - Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.1
8.10
Release Date
October 2019
Content Type
Programming Reference
Publication ID
B700-4003-079K
Language
English (United States)

This example scales input data using multiple methods—midrange, mean, maxabs, and range—in the same function call.

Input

  • Training data: scale_housing, as in Scale Example: ScaleMethod ('midrange')
  • Test data: tmpScale, created with this statement:
    CREATE MULTISET table tmpScale1 AS (
      SELECT * FROM ScaleMap (
      ON scale_housing
      USING
      TargetColumns ('[2:6]')
      MissValue ('omit')
      ) AS dt 
    ) WITH DATA;

SQL Call

SELECT * FROM Scale (
  ON scale_housing AS InputTable PARTITION BY ANY
  ON tmpScale1 AS statistic DIMENSION
  USING
  ScaleMethod ('midrange','mean','maxabs','range')
  Accumulate ('id')
) AS dt ORDER BY id,price,lotsize;

Output

 id price                lotsize              bedrooms           bathrms stories             scalemethod 
 -- -------------------- -------------------- ------------------ ------- ------------------- ----------- 
  1             -23037.5                782.5              0.125  -0.125               0.125 mean       
  1                 -1.0   0.5543175487465181                1.0    -1.0 -0.3333333333333333 midrange   
  1                  0.0   0.7771587743732591                1.0     0.0  0.3333333333333333 range      
  1   0.4745762711864407   0.8796992481203008                1.0     0.5                 0.5 maxabs     
  3             -15537.5              -2007.5              0.125  -0.125              -0.875 mean       
  3  -0.6774193548387096                 -1.0                1.0    -1.0                -1.0 midrange   
  3  0.16129032258064516                  0.0                1.0     0.0                 0.0 range      
  3    0.559322033898305  0.46015037593984964                1.0     0.5                0.25 maxabs     
  4              -4537.5               1582.5              0.125  -0.125               0.125 mean       
  4 -0.20430107526881722                  1.0                1.0    -1.0 -0.3333333333333333 midrange   
  4   0.3978494623655914                  1.0                1.0     0.0  0.3333333333333333 range      
  4   0.6836158192090396                  1.0                1.0     0.5                 0.5 maxabs     
  5              -4037.5               1292.5             -0.875  -0.125              -0.875 mean       
  5  -0.1827956989247312   0.8384401114206128               -1.0    -1.0                -1.0 midrange   
  5  0.40860215053763443   0.9192200557103064                0.0     0.0                 0.0 range      
  5   0.6892655367231638    0.956390977443609 0.6666666666666666     0.5                0.25 maxabs     
  6  0.03225806451612903  -0.3871866295264624                1.0    -1.0                -1.0 midrange   
  6   0.5161290322580645   0.3064066852367688                1.0     0.0                 0.0 range      
  6   0.7457627118644068   0.6255639097744361                1.0     0.5                0.25 maxabs     
  6                962.5               -907.5              0.125  -0.125              -0.875 mean       
  8  0.16129032258064516  -0.3871866295264624                1.0    -1.0  0.3333333333333333 midrange   
  8   0.5806451612903226   0.3064066852367688                1.0     0.0  0.6666666666666666 range      
  8   0.7796610169491526   0.6255639097744361                1.0     0.5                0.75 maxabs     
  8               3962.5               -907.5              0.125  -0.125               1.125 mean       
  9   0.7978494623655914 -0.03064066852367688                1.0    -1.0                -1.0 midrange   
  9   0.8989247311827957  0.48467966573816157                1.0     0.0                 0.0 range      
  9   0.9468926553672317   0.7218045112781954                1.0     0.5                0.25 maxabs     
  9              18762.5               -267.5              0.125  -0.125              -0.875 mean       
 10                  1.0   0.3593314763231198                1.0     1.0                 1.0 midrange   
 10                  1.0   0.6796657381615598                1.0     1.0                 1.0 range      
 10                  1.0   0.8270676691729323                1.0     1.0                 1.0 maxabs     
 10              23462.5                432.5              0.125   0.875               2.125 mean

Download a zip file of all examples and a SQL script file that creates their input tables from the attachment in the left sidebar.