TD_BinCodeFit Example | BinCodeFit | Teradata Vantage - Example: How To Use TD_BinCodeFit - Teradata VantageCloud Lake

Lake - Analyze Your Data with ClearScape Analytics™

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2026-02-20
dita:mapPath
tcl1683670667798.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
tcl1683670667798

Every complete example in this document is available in a zip file that you can download. The zip file includes a SQL script file that creates the input tables for the examples. If you are reading this document on https://docs.teradata.com/, you can download the zip file (SQLE-Analytic-Functions-Examples_xxxx) from the attachment in the left pane.

TD_BinCodeFit InputTable: bin_titanic_train

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

TD_BinCodeFit Input: FitInput table

 ColumnName   MinValue     MaxValue     Label      
 ---------- ------------ ------------ ---------- 
 age           0.00 	  20.00 	Young Age 
 age          21.00 	  45.00 	Middle Age
 age          46.00 	  90.00	 Old Age   

Example: Using Age Column with TD_BinCodeFit SQL Call

CREATE TABLE FitOutputTable AS (
  SELECT * FROM TD_BincodeFit (
    ON bin_titanic_train AS InputTable
    ON FitInputTable AS FitInput DIMENSION
    USING
    TargetColumns ('age')
    MethodType ('Variable-Width')
    MinValueColumn ('MinValue')
    MaxValueCOlumn ('MaxValue')
    LabelColumn ('Label')
    TargetColNames ('ColumnName')
  ) AS dt
) WITH DATA;

Example: Using Variable Width for Target Columns with TD_BinCodeFit SQL Call

CREATE TABLE FitOutputTable AS (
  SELECT * FROM TD_BincodeFit (
    ON bin_titanic_train AS InputTable
    ON FitInputTable AS FitInput DIMENSION
    USING
    TargetColumns ('[5]')
    MethodType ('Variable-Width')
    MinValueColumn ('MinValue')
    MaxValueCOlumn ('MaxValue')
    LabelColumn ('Label')
    TargetColNames ('ColumnName')
  ) AS dt
) WITH DATA;

TD_BinCodeFit Output

TD_ColumnName_BINFIT TD_MinValue_BINFIT TD_MaxValue_BINFIT TD_Label_BINFIT TD_Bins_BINFIT TD_IndexValue_BINFIT TD_MaxLenLabel_BINFIT age  
 -------------------- ------------------ ------------------ --------------
 age                        46.000000000       90.000000000 Old Age                      3                    0                    10 null
 age                        21.000000000       45.000000000 Middle Age                   3                    0                    10 null
 age                         0.000000000       20.000000000 Young Age                    3                    0                    10 null