TD_OrdinalEncodingFit Example | OrdinalEncodingFit - Example: How to Use TD_OrdinalEncodingFit - Analytics Database

Database Analytic Functions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-04-06
dita:mapPath
gjn1627595495337.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
jmh1512506877710
Product Category
Teradata Vantageā„¢

TD_OrdinalEncodingFit InputTable: OrdEnc_titanic_train

passenger survived pclass name gender age sibsp parch ticket fare cabin embarked
873 0 1 Carlsson; Mr. Frans Olof male 33 0 0 695 5.0000 B51 B53 B55 S
631 1 1 Barksworth; Mr. Algernon Henry Wilson male 80 0 0 27042 30.0000 A23 S
97 0 1 Goldschmidt; Mr. George B male 71 0 0 PC 17754 34.6542 A5 C
1000 0 1     71 0 0   34.6542    
488 0 1 Kent; Mr. Edward Austin male 58 0 0 11771 29.7000 B37 C
505 1 1 Maioni; Miss. Roberta female 16 0 0 110152 86.5000 B79 S

Example: TD_OrdinalEncodingFit SQL Call Using Auto Approach

SELECT * FROM TD_OrdinalEncodingFit (
ON ordinal_titanic_dataset AS InputTable
USING
TargetColumn('name','gender','ticket','cabin','embarked')
Approach ('AUTO')
StartValue (5, 10, 15, 0, -5)
DefaultValue (-1, -10, -15, 20, 0)
) AS dt ORDER BY 1,3;

TD_OrdinalEncodingFit Output Table Using Auto Approach

TD_ColumnName_ORDFIT TD_Category_ORDFIT TD_Value_ORDFIT TD_Index_ORDFIT name gender ticket cabin embarked
cabin   0 3 None None None None None
cabin A23 1 3 None None None None None
cabin A5 2 3 None None None None None
cabin B37 3 3 None None None None None
cabin B51 B53 B55 4 3 None None None None None
cabin B79 5 3 None None None None None
cabin TD_CATEGORY_COUNT 6 -1 None None None None None
cabin TD_OTHER_CATEGORY 20 -2 None None None None None
embarked   -5 4 None None None None None
embarked C -4 4 None None None None None
embarked S -3 4 None None None None None
embarked TD_OTHER_CATEGORY 0 -2 None None None None None
embarked TD_CATEGORY_COUNT 3 -1 None None None None None
name TD_OTHER_CATEGORY -1 -2 None None None None None
name   5 0 None None None None None
name TD_CATEGORY_COUNT 6 -1 None None None None None
name Barksworth; Mr. Algernon Henry Wilson 6 0 None None None None None
name Carlsson; Mr. Frans Olof 7 0 None None None None None
name Goldschmidt; Mr. George B 8 0 None None None None None
name Kent; Mr. Edward Austin 9 0 None None None None None
name Maioni; Miss. Roberta 10 0 None None None None None
gender TD_OTHER_CATEGORY -10 -2 None None None None None
gender TD_CATEGORY_COUNT 3 -1 None None None None None
gender   10 1 None None None None None
gender female 11 1 None None None None None
gender male 12 1 None None None None None
ticket TD_OTHER_CATEGORY -15 -2 None None None None None
ticket TD_CATEGORY_COUNT 6 -1 None None None None None
ticket   15 2 None None None None None
ticket 110152 16 2 None None None None None
ticket 11771 17 2 None None None None None
ticket 27042 18 2 None None None None None
ticket 695 19 2 None None None None None
ticket PC 17754 20 2 None None None None None
Multiple column support for TD_OrdinalEncoding, TD_OneHotEncoding, and TD_Histogram is available in release 17.20.03.07 and later. If you are using an older version, the TargetColumn argument accepts only one column.

CategoryTable: catTable

ColumnName Category ordinalValue
ticket 695 0
gender female 0
cabin B79 0
ticket 11771 1
gender male 1
cabin B51 B53 B55 1
ticket PC 17754 2
gender   2
cabin A5 2
ticket 27042 3
name Maioni; Miss.Roberta 0
cabin A23 3
ticket 110152 4
name Carlsson; Mr. Frans Olof 1
cabin B37 4
ticket   5
name Goldschmidt; Mr. George B 2
cabin   5
name Barksworth; Mr. Algernon Henry Wilson 3
embarked S 0
name Kent; Mr. Edward Austin 4
embarked C 1
name   5
embarked   2

Example: TD_OrdinalEncodingFit SQL Call Using List Approach

SELECT * FROM TD_OrdinalEncodingFit (
ON ordinal_titanic_dataset AS InputTable
ON catTable AS CategoryTable Dimension
USING
TargetColumn('name','gender','ticket','cabin','embarked')
Approach ('LIST')
TargetColumnNames('ColumnName')
CategoriesColumn('Category')
OrdinalValuesColumn ('ordinalValue')
DefaultValue (-1, -10, -15, 20, 0)
) AS dt ORDER BY 1,3;

TD_OrdinalEncodingFit Output Table Using List Approach

TD_ColumnName_ORDFIT TD_Category_ORDFIT TD_Value_ORDFIT TD_Index_ORDFIT name gender ticket cabin embarked
cabin B79 0 3 None None None None None
cabin B51 B53 B55 1 3 None None None None None
cabin A5 2 3 None None None None None
cabin A23 3 3 None None None None None
cabin B37 4 3 None None None None None
cabin   5 3 None None None None None
cabin TD_CATEGORY_COUNT 6 -1 None None None None None
cabin TD_OTHER_CATEGORY 20 -2 None None None None None
embarked TD_OTHER_CATEGORY 0 -2 None None None None None
embarked S 0 4 None None None None None
embarked C 1 4 None None None None None
embarked   2 4 None None None None None
embarked TD_CATEGORY_COUNT 3 -1 None None None None None
name TD_OTHER_CATEGORY -1 -2 None None None None None
name Maioni; Miss. Roberta 0 0 None None None None None
name Carlsson; Mr. Frans Olof 1 0 None None None None None
name Goldschmidt; Mr. George B 2 0 None None None None None
name Barksworth; Mr. Algernon Henry Wilson 3 0 None None None None None
name Kent; Mr. Edward Austin 4 0 None None None None None
name   5 0 None None None None None
name TD_CATEGORY_COUNT 6 -1 None None None None None
gender TD_OTHER_CATEGORY -10 -2 None None None None None
gender female 0 1 None None None None None
gender male 1 1 None None None None None
gender   2 1 None None None None None
gender TD_CATEGORY_COUNT 3 -1 None None None None None
ticket TD_OTHER_CATEGORY -15 -2 None None None None None
ticket 695 0 2 None None None None None
ticket 11771 1 2 None None None None None
ticket PC 17754 2 2 None None None None None
ticket 27042 3 2 None None None None None
ticket 110152 4 2 None None None None None
ticket   5 2 None None None None None
ticket TD_CATEGORY_COUNT 6 -1 None None None None None