Scale Example: Use Training Data to Scale Test Data - 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 creates statistics using ScaleMap on a training data set and then uses these statistics to scale a similar test data set.

Input

scale_housing_test
type id price lotsize bedrooms bathrms stories
bungalow 11 90000 7200 3 2 1
classic 12 30500 3000 2 1 1
classic 13 27000 1700 3 1 2
classic 14 36000 2880 3 1 1
classic 15 37000 3600 2 1 1

SQL Call to Create Statistics Table from Training Data

CREATE multiset table scale_stat AS (
SELECT * FROM ScaleMap (
	ON scale_housing
	USING
	TargetColumns('[2:6]')
	MissValue ('omit')
  ) AS dt
) WITH DATA;

SQL Call to Scale Test Data

SELECT * FROM Scale (
  ON scale_housing_test AS InputTable PARTITION BY ANY
  ON scale_stat AS statistic DIMENSION
  USING
  ScaleMethod ('midrange')
  Accumulate ('id')
) AS dt ORDER BY id,price,lotsize;

Output

 id price               lotsize             bedrooms bathrms stories             
 -- ------------------- ------------------- -------- ------- ------------------- 
 11   1.064516129032258  1.3064066852367688      1.0     1.0                -1.0
 12 -1.4946236559139785  -1.033426183844011     -1.0    -1.0                -1.0
 13 -1.6451612903225807 -1.7576601671309193      1.0    -1.0 -0.3333333333333333
 14 -1.2580645161290323 -1.1002785515320335      1.0    -1.0                -1.0
 15 -1.2150537634408602 -0.6991643454038997     -1.0    -1.0                -1.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.