Scale Example: ScaleMethod ('midrange'), Intercept (-min) - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
8.10
1.1
Published
October 2019
Language
English (United States)
Last Update
2019-12-31
dita:mapPath
ima1540829771750.ditamap
dita:ditavalPath
jsj1481748799576.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantage™

This example is like Scale Example: ScaleMethod ('midrange') except that the Intercept syntax element has the value -min (where min is the global minimum value). This example also specifies a Multiplier value, but it is the default, as in Scale Example: ScaleMethod ('midrange').

Input

  • InputTable: scale_housing, as in Scale Example: ScaleMethod ('midrange')
  • Statistic: scale2, created with this statement:
    CREATE MULTISET table scale2 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 scale2 AS statistic DIMENSION
  USING
  ScaleMethod ('midrange')
  Accumulate ('id')
  Intercept ('-min')
  Multiplier (1)
) AS dt ORDER BY id,price,lotsize;

Output

In this example, the intercept syntax element is “-min”. As shown in the description of the Intercept syntax element, in this case the intercept is calculated as:

scaledmin=(minX- location)/scale

The formula for computing the scaled value X' from the input value X becomes:

X'=-scaledmin+multiplier*(X-location)/scale

ScaleMethod is “midrange”, so location and scale are the same as shown in Scale Example: ScaleMethod ('midrange').

For example, consider the value in the Price column in row id = 3:
  • The value in the input table is 49500.
  • In this example, multiplier has its default value, 1.
  • scaledmin is calculated using the above equation:

    scaledmin= (minX-location)/scale= (42000-65250)/23250= -1

  • The scaled value shown in the output table is calculated as follows:

    X'=-scaledmin+multiplier*(X-location)/scale= -(-1)+1* (49500-65250)/23250= 0.3225806

 id price               lotsize            bedrooms bathrms stories            
 -- ------------------- ------------------ -------- ------- ------------------ 
  1                 0.0 1.5543175487465182      2.0     0.0 0.6666666666666667
  3 0.32258064516129037                0.0      2.0     0.0                0.0
  4  0.7956989247311828                2.0      2.0     0.0 0.6666666666666667
  5  0.8172043010752688 1.8384401114206128      0.0     0.0                0.0
  6   1.032258064516129 0.6128133704735377      2.0     0.0                0.0
  8  1.1612903225806452 0.6128133704735377      2.0     0.0 1.3333333333333333
  9  1.7978494623655914 0.9693593314763231      2.0     0.0                0.0
 10                 2.0 1.3593314763231197      2.0     2.0                2.0

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