MetricWithCI<T>

Models & Types · AiDotNet.Evaluation.Results.Core

Represents a metric value with optional confidence interval and metadata.

For Beginners

When you measure something, you get a single number (the point estimate). But that number has uncertainty. The confidence interval tells you the range where the true value likely falls. For example: “Accuracy = 0.85 [0.82, 0.88]” means the accuracy is about 85%, but could reasonably be anywhere from 82% to 88%.

How It Works

This is the fundamental building block for all evaluation metrics. It contains the point estimate, confidence interval, and metadata about how the metric was computed.

Constructors

Constructor Summary
MetricWithCI() Default parameterless constructor for serialization.
MetricWithCI(T value, T lowerBound, T upperBound, double confidenceLevel, ConfidenceIntervalMethod ciMethod, string name, MetricDirection direction) Initializes a new metric with a confidence interval.
MetricWithCI(T value, string name, MetricDirection direction) Initializes a new metric with just a point estimate.

Properties

Property Summary
ConfidenceIntervalMethod? CIMethod { get; set; } Method used to compute the confidence interval.
MetricDirection Direction { get; set; } Whether higher values indicate better performance for this metric.
T IntervalWidth { get; } Width of the confidence interval (upper - lower).
T LowerBound { get; set; } Lower bound of the confidence interval.
T MarginOfError { get; } Half-width of the confidence interval (margin of error).
T StandardDeviation { get; set; } Standard deviation of the metric (e.g., across CV folds).
T StandardError { get; set; } Standard error of the metric.
T UpperBound { get; set; } Upper bound of the confidence interval.
T Value { get; set; } The point estimate (main value) of the metric.
bool HasConfidenceInterval { get; } Whether a confidence interval is available.
bool IsValid { get; } Whether this metric value is valid (not NaN or infinite).
double? ConfidenceLevel { get; set; } Confidence level (e.g., 0.95 for 95% CI).
int? SampleCount { get; set; } Number of samples used to compute the metric.
string Category { get; set; } Category of the metric (e.g., “Classification”, “Regression”).
string Description { get; set; } Human-readable description of the metric.
string Name { get; set; } Name of the metric (e.g., “Accuracy”, “MSE”).

Methods

Method Summary
bool IsSignificantlyBetterThan(MetricWithCI<T> other) Checks if this metric is significantly better than another at the given significance level.
string Format(int decimalPlaces, bool includeCI) Formats the metric for display.
string FormatAsPercentage(int decimalPlaces, bool includeCI) Formats the metric as a percentage.
string ToString() Returns a string representation of the metric.