pub struct MetricWithVariance {
pub mean: f64,
pub std_dev: f64,
pub ci_95: f64,
pub min: f64,
pub max: f64,
pub n: usize,
}Expand description
A metric with variance and confidence interval.
Tracks the mean, standard deviation, and 95% confidence interval for a metric computed across multiple samples/runs/datasets.
§Example
use anno_eval::eval::MetricWithVariance;
let metric = MetricWithVariance::from_samples(&[0.85, 0.87, 0.82, 0.88, 0.84]);
println!("F1: {:.1}% ± {:.1}% (95% CI)", metric.mean * 100.0, metric.ci_95 * 100.0);
// F1: 85.2% ± 2.1% (95% CI)Fields§
§mean: f64Mean value of the metric
std_dev: f64Standard deviation
ci_95: f6495% confidence interval (±)
min: f64Minimum observed value
max: f64Maximum observed value
n: usizeNumber of samples
Implementations§
Source§impl MetricWithVariance
impl MetricWithVariance
Sourcepub fn from_samples(samples: &[f64]) -> Self
pub fn from_samples(samples: &[f64]) -> Self
Create from a slice of sample values.
Uses sample standard deviation (Bessel’s correction) and t-distribution approximation for 95% CI.
Sourcepub fn format_with_ci(&self) -> String
pub fn format_with_ci(&self) -> String
Format as “mean ± ci95” string.
Sourcepub fn format_with_range(&self) -> String
pub fn format_with_range(&self) -> String
Format as “mean (min-max)” string.
Sourcepub fn coefficient_of_variation(&self) -> f64
pub fn coefficient_of_variation(&self) -> f64
Get coefficient of variation (CV = std_dev / mean).
Trait Implementations§
Source§impl Clone for MetricWithVariance
impl Clone for MetricWithVariance
Source§fn clone(&self) -> MetricWithVariance
fn clone(&self) -> MetricWithVariance
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for MetricWithVariance
Source§impl Debug for MetricWithVariance
impl Debug for MetricWithVariance
Source§impl Default for MetricWithVariance
impl Default for MetricWithVariance
Source§impl<'de> Deserialize<'de> for MetricWithVariance
impl<'de> Deserialize<'de> for MetricWithVariance
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for MetricWithVariance
impl Display for MetricWithVariance
Source§impl PartialEq for MetricWithVariance
impl PartialEq for MetricWithVariance
Source§fn eq(&self, other: &MetricWithVariance) -> bool
fn eq(&self, other: &MetricWithVariance) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for MetricWithVariance
impl Serialize for MetricWithVariance
impl StructuralPartialEq for MetricWithVariance
Auto Trait Implementations§
impl Freeze for MetricWithVariance
impl RefUnwindSafe for MetricWithVariance
impl Send for MetricWithVariance
impl Sync for MetricWithVariance
impl Unpin for MetricWithVariance
impl UnsafeUnpin for MetricWithVariance
impl UnwindSafe for MetricWithVariance
Blanket Implementations§
impl<T> Boilerplate for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.