ISmDiscriminantAnalysis.RelevanceMeasure

Syntax

RelevanceMeasure: IBinaryModelRelevanceMeasure;

Description

The RelevanceMeasure property returns binary classification quality criteria.

Comments

Criteria of classification quality are calculated, if explanatory series is binary.

Example

To execute the example, add links to the MathFin, Stat system assemblies.

Sub UserProc;
Var
    DA: SmDiscriminantAnalysis;
    y, x1, x2, x3, x4, x5, x6, x7, x8: Array[
60Of Double;
    Ex: ISlSeries;
    res, i, j: Integer;
    resM: Array 
Of Integer;
    str: String;
Begin
    DA := 
New SmDiscriminantAnalysis.Create;
    
// Initial data: sixty objects with eight attributes
    For i := 0 To 59 Do
        x1[i] := Math.RandBetween(
0100);
        x2[i] := Math.RandBetween(
0100);
        x3[i] := Math.RandBetween(
0100);
        x4[i] := Math.RandBetween(
0100);
        x5[i] := Math.RandBetween(
0100);
        x6[i] := Math.RandBetween(
0100);
        x7[i] := Math.RandBetween(
0100);
        x8[i] := Math.RandBetween(
0100);
    
End For;
    
// Explained series values
    For i := 0 To 59 Do
        y[i] := Math.RandBetweenI(
01);
    
End For;
    
// Set explained variable
    DA.Dependent.Value := y;
    
// Set explanatory variables
    Ex := DA.Explanatories;
    Ex.Add.Value := x1; Ex.Add.Value := x5;
    Ex.Add.Value := x2; Ex.Add.Value := x6;
    Ex.Add.Value := x3; Ex.Add.Value := x7;
    Ex.Add.Value := x4; Ex.Add.Value := x8;
    
// Run calculation and output results
    res := DA.Execute;
    
If res <> 0 Then
        Debug.WriteLine(DA.Errors);
    
Else
        Debug.WriteLine(
" == Summary results of classification == ");
        res := DA.ClassCount;
        Debug.WriteLine(
"Number of classes: " + res.ToString);
        resM := DA.ClassificationSummary;
        
For i := 0 To res - 1 Do
            
For j := 0 To res - 1 Do
                str := str + 
" " + (resM[i, j] As Integer).ToString;
            
End For;
            str := str + 
" | " + (resM[i, res] As Integer).ToString;
            Debug.WriteLine(str);
            str := 
"";
        
End For;
        str := 
"- - - - - - - - ";
        Debug.WriteLine(str);
        str := 
"";
        
For j := 0 To DA.ClassCount - 1 Do
                str := str + 
" " + (resM[res, j] As Integer).ToString;
            
End For;
        str := str + 
" | " + (resM[res, res] As Integer).ToString;
        Debug.WriteLine(str);
        
// Display classification quality criteria      
        Debug.WriteLine(" == Classification quality criteria == ");
        Debug.WriteLine(
"Overall accuracy: " + DA.RelevanceMeasure.Accuracy.ToString);
        Debug.WriteLine(
"F - estimation: " + DA.RelevanceMeasure.F1.ToString);
        Debug.WriteLine(
"Accuracy of positive result: " + DA.RelevanceMeasure.Precision.ToString);
        Debug.WriteLine(
"Accuracy of positive result: " + DA.RelevanceMeasure.Recall.ToString);
    
End If;
End Sub UserProc;

After executing the example, the console window will display classification results and its quality criteria.

See also:

ISmDiscriminantAnalysis