PrecisionMetric<T>
Models & Types · AiDotNet.Evaluation.Metrics.Classification
Computes precision (positive predictive value): the proportion of positive predictions that are correct.
Implements: IClassificationMetric<T>
For Beginners
Precision answers: “When the model predicts positive, how often is it correct?” High precision means few false positives (false alarms). A spam filter with 99% precision means only 1% of emails it flags as spam are actually legitimate.
How It Works
Precision = TP / (TP + FP) = True Positives / Predicted Positives
When to prioritize precision:
- When false positives are costly (blocking legitimate transactions, accusing innocent people)
- When you need high confidence in positive predictions
Multi-class: For multi-class problems, use averaging (micro, macro, weighted) to combine per-class precision values.
Constructors
| Constructor | Summary |
|---|---|
PrecisionMetric(AveragingMethod averaging) |
Initializes a new precision metric with default positive label (1). |
PrecisionMetric(T positiveLabel, AveragingMethod averaging) |
Initializes a new precision metric with an explicit positive label. |
Properties
| Property | Summary |
|---|---|
MetricDirection Direction { get; } |
|
T MaxValue { get; } |
|
T MinValue { get; } |
|
bool RequiresProbabilities { get; } |
|
bool SupportsMultiClass { get; } |
|
string Category { get; } |
|
string Description { get; } |
|
string Name { get; } |
Methods
| Method | Summary |
|---|---|
MetricWithCI<T> ComputeWithCI(ReadOnlySpan<T> predictions, ReadOnlySpan<T> actuals, ConfidenceIntervalMethod ciMethod, double confidenceLevel, int bootstrapSamples, int? randomSeed) |
|
T Compute(ReadOnlySpan<T> predictions, ReadOnlySpan<T> actuals) |