Search code examples
machine-learningdeep-learningdata-mininganomaly-detection

One-Class SVM: Precision, recall, and F1


I have a question

I have written the code below by using sklearn

self.model = SVM.OneClassSVM(gamma='scale', kernel='rbf').fit(training_set)
classification_report(self.ground_truth_label, self.predicted_results, target_names=target_names)

However, this picture below shows f1 score (Macro) is not located between precision and recall

I know f1 = (2 * precision * recall) / (precision + recall)

Why...?

Thank you for your explanation !

enter image description here


Solution

  • The macro average f1-score given by classification_report is the unweighted average of the f1-scores for the two classes in your dataset, i.e.

    (0.12 + 0.67) / 2 ≈ 0.40

    It is not, as you might have thought, the f1-score computed with the macro averages of precision and recall.


    To put it in another way:

    it is the average of all f1-scores

    and

    it is not the f1-score of the (precision and recall) averages