TD_ROC Example | ROC | Teradata Vantage - Example: How to Use TD_ROC - 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_ROC Input Table

model id observation probability 
----- -- ----------- ----------- 
    1  2 1           0.500000000
    1  1 0           0.150000000
    2  1 1           0.250000000
    2  2 0           0.550000000
    3  2 1           0.250000000
    3  1 0           0.450000000

TD_ROC SQL Call

SELECT * from TD_ROC(
 ON roc_input AS InputTable
 OUT PERMANENT TABLE OutputTable(RocTable)
 USING
 ModelIDColumn ('model')
 ProbabilityColumn ('probability')
 ObservationColumn ('observation')
 PositiveLabel ('1')
 NumThresholds (5)
 AUC('true')
 GINI('true')
)As dt;

TD_ROC Output Table

model AUC         GINI         
----- ---         ----         
    1 1.000000000  1.000000000
    3 0.500000000  0.000000000
    2 0.000000000 -1.000000000

ROC Output Table

SELECT * FROM RocTable;
model threshold_value tpr         fpr        
----- --------------- ---         ---        
    1     0.500000000 1.000000000 0.000000000
    1     1.000000000 0.000000000 0.000000000
    1     0.250000000 1.000000000 0.000000000
    1     0.750000000 0.000000000 0.000000000
    1     0.000000000 1.000000000 1.000000000
    2     0.250000000 1.000000000 1.000000000
    2     0.000000000 1.000000000 1.000000000
    2     1.000000000 0.000000000 0.000000000
    2     0.750000000 0.000000000 0.000000000
    2     0.500000000 0.000000000 1.000000000
    3     0.500000000 0.000000000 0.000000000
    3     1.000000000 0.000000000 0.000000000
    3     0.750000000 0.000000000 0.000000000
    3     0.250000000 1.000000000 1.000000000
    3     0.000000000 1.000000000 1.000000000