ISmCART.ROCcurve

Syntax

ROCcurve: IROCcurve;

Description

The ROCcurve property returns ROC curve parameters.

Comments

A ROC curve is a graph that enables the user to assess the quality of binary classification. A ROC curve displays relation between the share of objects from the total number of attribute bearers that are correctly identifier as attribute bearers, and the share of objects from the total number of objects that are not attribute bearers and that are by error identifier as attribute bearers on varying of decision rule threshold.

Thus, a ROC curve is calculated if an explanatory series is binary.

A ROC curve is plotted by laying off the obtained sensitivity values along the Y axis, and (1 - specificity) along the X axis.

Example

To execute the example, add a link to the Stat system assembly.

Sub UserProc;
Var
    res, i: Integer;
    CART: SmCART;
    ROCcurve: IROCcurve;
    y: Array[
16Of Integer;
    x1: Array[
16Of Integer;
    x2: Array[
16Of Integer;
    x3dbl: Array[
16Of Double;
    x4cat: Array[
16Of Integer;
    OneMinusSpecificity, Sensitivity: Array 
Of Double;
Begin
    
// Create a method
    CART := New SmCART.Create;
    
// Set initial data
    // Set values corresponding to  age group
    y[0] := 1000; y[1] := 1000; y[2] := 1000; y[3] := 1000;
    y[
4] := 1000; y[5] := 1000; y[6] := 1000; y[7] := 1000;
    y[
8] := 1000; y[9] := 5002; y[10] := 5002; y[11] := 5002;
    y[
12] := 5002; y[13] := 5002; y[14] := 5002; y[15] := 5002;
    
// Set values, corresponding to social status
    x1[0] := 0; x1[1] := 0; x1[2] := 0; x1[3] := 0;
    x1[
4] := 0; x1[5] := 0; x1[6] := 0; x1[7] := 0;
    x1[
8] := 0; x1[9] := 1; x1[10] := 1; x1[11] := 1;
    x1[
12] := 1; x1[13] := 1; x1[14] := 1; x1[15] := 1;
    
// Set values, corresponding to social status
    x2[0] := 10; x2[1] := 10; x2[2] := 10; x2[3] := 10;
    x2[
4] := 10; x2[5] := 20; x2[6] := 20; x2[7] := 20;
    x2[
8] := 20; x2[9] := 10; x2[10] := 10; x2[11] := 20;
    x2[
12] := 20; x2[13] := 20; x2[14] := 20; x2[15] := 20;

    // Set values of explanatory quantitative series
    x3dbl[0] := 1; x3dbl[1] := 2; x3dbl[2] := 3; x3dbl[3] := 5;
    x3dbl[
4] := 4; x3dbl[5] := 6; x3dbl[6] := 7; x3dbl[7] := 8;
    x3dbl[
8] := 9; x3dbl[9] := 9; x3dbl[10] := 10; x3dbl[11] := 10;
    x3dbl[
12] := 11; x3dbl[13] := 12; x3dbl[14] := 13; x3dbl[15] := 14;
    
// Set values of explanatory categorical series
    x4cat[0] := 1; x4cat[1] := 1; x4cat[2] := 1; x4cat[3] := 1;
    x4cat[
4] := 1; x4cat[5] := 1; x4cat[6] := 1; x4cat[7] := 2;
    x4cat[
8] := 2; x4cat[9] := 2; x4cat[10] := 2; x4cat[11] := 2;
    x4cat[
12] := 3; x4cat[13] := 3; x4cat[14] := 3; x4cat[15] := 3;
    
// Determine maximum number of levels in tree
    CART.TreeSizeSpecification.MaximumNumberOfLevels := 3;
    
// Determine minimum number of observations that can be in tree node
    CART.TreeSizeSpecification.MinimumNumberOfCases := 2;
    
// Consider each category as an attribute
    CART.TreeSizeSpecification.ReduceCategories := True;
    
// Set explained series
    CART.Dependent.Value := y;
    
// Set explanatory sequence series
    CART.ExplanatoriesOrdered.Add.Value := x1;
    CART.ExplanatoriesOrdered.  Add.Value := x2;    
    CART.ExplanatoriesContinuous.Add.Value := x3dbl;
    CART.ExplanatoriesCategorical.Add.Value := x4cat;
    
// Execute calculation and display values to the console window
    res := CART.Execute;
    ROCcurve := CART.ROCcurve;
    Debug.WriteLine(CART.Errors);
    
If res <> 0 Then
        Debug.WriteLine(
"Failed");
    
Else
        
If ROCcurve <> Null Then
            Debug.WriteLine(
"ROC curve data:");
            Debug.Indent;
            Debug.WriteLine(
"Specifity:");
            Debug.Indent;
            OneMinusSpecificity := ROCcurve.OneMinusSpecificity;
            
For i := 0 To OneMinusSpecificity.Length - 1 Do
                Debug.WriteLine(OneMinusSpecificity[i]);
            
End For;
            Debug.Unindent;
            Debug.WriteLine(
"Sensitivity:");
            Debug.Indent;
            Sensitivity := ROCcurve.Sensitivity;
            
For i := 0 To Sensitivity.Length - 1 Do
                Debug.WriteLine(Sensitivity[i]);
            
End For;
        End If;
        
// Display classification quality criteria
        Debug.Unindent;
        Debug.Unindent;
        Debug.WriteLine(
" == Qualification criteria of classification == ");
        Debug.WriteLine(
"Overall accuracy: " + CART.RelevanceMeasure.Accuracy.ToString);
        Debug.WriteLine(
"F - estimate: " + CART.RelevanceMeasure.F1.ToString);
        Debug.WriteLine(
"Number of truly positive values: " + CART.RelevanceMeasure.TruePositive.ToString);
        Debug.WriteLine(
"Number of truly negative values: " + CART.RelevanceMeasure.TrueNegative.ToString);
    
End If;
End Sub UserProc;

After executing the example, the console window will display ROC curve data and classification quality criteria.

See also:

ISmCART