Module

Learn.Metrics.ConfusionMatrix

Package
purescript-learn
Repository
carldata/purescript-learn

Compute confusion matrix to evaluate the accuracy of any classifier.

#ConfusionMatrix Source

type ConfusionMatrix = { fn :: Int, fp :: Int, tn :: Int, tp :: Int }

#calculate Source

calculate :: Vector Boolean -> Vector Boolean -> ConfusionMatrix

Create confusion matrix from correct values and estimated targets returned by classifier

#precision Source

precision :: ConfusionMatrix -> Number

precision = TP / (TP + FP)

#recall Source

recall :: ConfusionMatrix -> Number

recall = TP / (TP + TN)

#accuracy Source

accuracy :: ConfusionMatrix -> Number

accuracy = (TP + TN) / (TP + TN + FP + FN)

#fscore Source

fscore :: ConfusionMatrix -> Number

F1 score = 2 * (precision * recall) / (precision + recall)