5.4.6 - Z-Score - Teradata Warehouse Miner

In-Database Analytic Functions User Guide

prodname
Teradata Warehouse Miner
vrm_release
5.4.6
created_date
November 2018
category
User Guide
featnum
B035-2306-118K

Purpose

Similar to a Sigmoid transformation, a Z-Score transformation provides rescaling of continuous numeric data in a more sophisticated way than a Rescaling transformation. In a Z-Score transformation, a numeric column is transformed into its Z-score based on the mean value and standard deviation of the data in the column. Z-Score transforms each column value into the number of standard deviations from the mean value of the column. This non-linear transformation is useful in data mining rather than in a linear Rescaling transformation.

The Z-Score transformation supports both numeric and date type input data.

For the formulas associated with the Z-Score function, see Teradata Warehouse Miner User Guide: Volume 2, ADS Generation (B035-2301).

Syntax

call twm. td_analyze('vartran','database=twm_source;tablename=twm_customer;General Parameters;zscore=columns (values),datatype (integer);');

Required Parameters

columns
Controls the name of the output (transformed) column and its data type. The columns parameter is required by all transformations except Derive. A separate transformation is performed for each column in the list. If a column name is followed by a forward slash and a name, the name after the slash becomes the name of the transformed column in the resultant output table. Otherwise the column name is used as the output column name.
For the Derive transformation, the outputname parameter controls the naming of the transformed output column.
database
The database containing the input table.
tablename
The input table to build a predictive model from.
vartran
Required to run a variable transformation. Enclose the 'vartran' parameter in single quotes.
zscore
Identifies the type of transformation being performed.

Optional Parameters

datatype
For all transformation types, the datatype casts the column to a desired database data type provided it is compatible with the transformed data.
Allowed output types include:
  • byteint
  • char
  • date
  • decimal
  • float
  • integer
  • smallint
  • time
  • timestamp
  • varchar
  • bigint
  • number
fallback
When true, requests a mirrored copy of the output table in the Teradata Database when outputstyle=table.
gensqlonly
When true, the SQL for the requested transformations is returned as a result set but not run. When not specified or set to false, the SQL is run but not returned.
indexcolumns
When true, requests the output table contain the index columns when outputstyle=table.
indexunique
When true, requests the output table contain a unique primary index when outputstyle=table.
keycolumns
When null replacement is requested, either through a Null Replacement transformation or in combination with a Bin Code, Derive, Design Code, Recode, Rescale, Sigmoid, or Z Score transformation, the keycolumns parameter must be specified. The column or columns listed must form a unique key into the input and output table of the transformation.
lockingclause

Requests the generated SQL contain the given locking clause in the appropriate location depending on the output style.

An example of a locking clause when the output style defaults to select is:

LOCKING mydb.mytable FOR ACCESS;

multiset
When true, requests an output table that can contain duplicate rows when outputstyle=table.
noindex
When true, requests the output table contain no index columns when outputstyle=table.
nullstyle
Data types supported by various nullstyle parameters are:
Data Type Description Example
literal,value numeric, character, and date nullstyle (literal,value)
mean numeric and date nullstyle (mean)
median numeric and date nullstyle (median)
medianwithoutaveraging any supported data type nullstyle (medianwithoutaveraging)
mode any supported date type nullstyle (mode)
imputed,table any supported data type nullstyle (imputed,tablename)

If date values are entered, the keyword DATE must precede the date value, and do not enclose in single quotes.

outputdatabase
The database containing the resulting output table when outputstyle=table or view.
outputstyle
Allowed output styles are:
  • select
  • table
  • view
If outputstyle is not specified, the function generates a SELECT statement and does not create a table or view.
outputstyle={select|table|view}
outputtablename
The name of the output table when outputstyle=table or view.
overwrite

When overwrite is set to true (default), the output tables are dropped before creating new ones.

whereclause
Requests the generated SQL containing the given WHERE clause in appropriate places in the generated SQL. This is independent of the output style requested.

Examples

These examples show how to use Z-Score. To run the provided examples, the td_analyze function must be installed in a database called twm and the TWM tutorial data must be installed in the twm_source database.

The following example demonstrates the Z-Score transformation.

call twm.td_analyze('vartran','database=twm_source;tablename=twm_customer;zscore=columns(age,income/inc),datatype(integer);');

The following example demonstrates combined null replacement. The keycolumns parameter must be included as a general parameter when null value replacement is performed.

call twm.td_analyze('vartran','database=twm_source;tablename=twm_customer;keycolumns=cust_id;zscore=nullstyle(literal,0),columns(age,income);');