pub struct R2 { /* private fields */ }Expand description
R² (coefficient of determination).
Uses Welford’s online algorithm for the variance of the truth, avoiding
the catastrophic cancellation that sum(y²) - n · mean(y)² suffers on
large-offset, small-variance data. Returns None when fewer than 2
samples have been seen or when the truth variance is zero (constant
truth).
Implementations§
Trait Implementations§
Source§impl Metric for R2
impl Metric for R2
Source§type Prediction = f64
type Prediction = f64
The prediction type for this metric.
Source§fn update(&mut self, truth: f64, prediction: f64) -> Result<(), RillError>
fn update(&mut self, truth: f64, prediction: f64) -> Result<(), RillError>
Incorporate a single observation.
Source§fn value(&self) -> Option<f64>
fn value(&self) -> Option<f64>
Current metric value, or
None if not enough data has been seen.Source§fn samples_seen(&self) -> u64
fn samples_seen(&self) -> u64
How many observations have been incorporated.
Auto Trait Implementations§
impl Freeze for R2
impl RefUnwindSafe for R2
impl Send for R2
impl Sync for R2
impl Unpin for R2
impl UnsafeUnpin for R2
impl UnwindSafe for R2
Blanket Implementations§
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