1.0 - 8.00 - Scale Example 3: Use Training Data to Scale Test Data - Teradata Vantage

Teradata® Vantage Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.0
8.00
Release Date
May 2019
Content Type
Programming Reference
Publication ID
B700-4003-098K
Language
English (United States)

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
types 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 "input" PARTITION BY ANY
  ON scale_stat AS STATISTIC DIMENSION
  USING
  ScaleMethod ('midrange')
  Accumulate ('id')
) AS dt;

Output

id price lotsize bedrooms bathrms stories
11 1.06451612903226 1.30640668523677 1 1 -1
13 -1.64516129032258 -1.75766016713092 1 -1 -0.333333333333333
15 -1.21505376344086 -0.6991643454039 -1 -1 -1
12 -1.49462365591398 -1.03342618384401 -1 -1 -1
14 -1.25806451612903 -1.10027855153203 1 -1 -1