TOnClassifyTest Event

type TOnClassifyTest = procedure(Sender: TObject; var Succes: double) of object;

Event type used to determine classification accuracy.

Event used by TClassifier object to test the classification accuracy. The method needs to test the accuray of the classification and return result in the Success parameter. The following example shows the typical pattern, how this event is to be implemented:

var i, k: Integer;
begin
    k := 0;
    for i := 0 to Length(Examples)-1 do
    begin
        if Examples[i].ClassIndex = NaiveBayes1.Classify(Examples[i].Discrete, Examples[i].Float) then Inc(k);
    end;
    Success := k/Length(Examples);
end;

Examples

delphi
var i, k: Integer;
begin
    k := 0;
    for i := 0 to Length(Examples)-1 do
begin
    if Examples[i].ClassIndex = NaiveBayes1.Classify(Examples[i].Discrete, Examples[i].Float) then Inc(k);
end;
Success := k/Length(Examples);
end;