HMath.DeepLearning.Metrics¶
Module index · Numerical conventions
Description
Classification metrics. Empty samples are rejected, zero-denominator precisionrecallF1 are defined as zero. Confusion matrix rows are truth, columns prediction. ROC ties count one half; PR AUC uses grouped-threshold trapezoids from recall=0,precision=1 (distinct from average precision).
On this page¶
| API | Purpose |
|---|---|
| ClassificationMetrics | Accuracy and per-class precision,recall,and F1 values ordered by class index. |
| ClassificationMetrics | Declaration and type contract below. |
| accuracy | Fraction of correctly predicted samples. |
| precisionByClass | Per-class true positives divided by predicted positives; ordering follows class indices. |
| recallByClass | Per-class true positives divided by actual positives. |
| f1ByClass | Per-class harmonic mean of precision and recall, following the metric function's zero-denominator convention. |
| confusionMatrix | Count [trueClass,predictedClass] pairs for a positive explicit class count. |
| classificationMetrics | Return accuracy and per-class precision, recall, and F1 with zero for undefined class denominators. |
| topKAccuracy | Measure whether truth lies among descending top-k scores; equal scores prefer the smaller class index. |
| rocAUC | Compute the exact positive/negative rank-pair ROC area; both classes are required and ties count half. |
| prAUC | Integrate the precision-recall curve by grouped-score trapezoids, requiring at least one positive example. |
| perplexity | Exponentiate the negative mean true-token log probability; empty or positive log probabilities fail. |
| cosineSimilarityMatrix | Compare every [M,D] row with every [N,D] row using scale-safe unit vectors; zero vectors fail. |
| marginRankingLoss | Mean hinge on signed (+/-1) pair ordering with a nonnegative finite margin. |
Documentation
ClassificationMetrics
data ClassificationMetrics Source #
Accuracy and per-class precision,recall,and F1 values ordered by class index.
Constructors
| ClassificationMetrics | |
Fields
| |
Instances
| Show ClassificationMetrics Source # | |
Defined in HMath.DeepLearning.Metrics Methods showsPrec :: Int -> ClassificationMetrics -> ShowS # show :: ClassificationMetrics -> String # showList :: [ClassificationMetrics] -> ShowS # | |
| Eq ClassificationMetrics Source # | |
Defined in HMath.DeepLearning.Metrics Methods (==) :: ClassificationMetrics -> ClassificationMetrics -> Bool # (/=) :: ClassificationMetrics -> ClassificationMetrics -> Bool # | |
confusionMatrix
confusionMatrix :: Int -> [Int] -> [Int] -> Either MathError [[Int]] Source #
Count [trueClass,predictedClass] pairs for a positive explicit class count.
classificationMetrics
classificationMetrics :: Int -> [Int] -> [Int] -> Either MathError ClassificationMetrics Source #
Return accuracy and per-class precision, recall, and F1 with zero for undefined class denominators.
topKAccuracy
topKAccuracy :: Int -> [Int] -> [[Double]] -> Either MathError Double Source #
Measure whether truth lies among descending top-k scores; equal scores prefer the smaller class index.
rocAUC
rocAUC :: [Bool] -> [Double] -> Either MathError Double Source #
Compute the exact positive/negative rank-pair ROC area; both classes are required and ties count half.
prAUC
prAUC :: [Bool] -> [Double] -> Either MathError Double Source #
Integrate the precision-recall curve by grouped-score trapezoids, requiring at least one positive example.
perplexity
perplexity :: [Double] -> Either MathError Double Source #
Exponentiate the negative mean true-token log probability; empty or positive log probabilities fail.