TD_ROC Example | ROC | Teradata Vantage - Example: How to Use TD_ROC - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

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