Struct ConfusionStatsState
pub struct ConfusionStatsState { /* private fields */ }Expand description
Accumulates confusion-matrix counts (TP, FP, FN) across an epoch.
Used by metrics derived from confusion-matrix ratios (precision, recall, etc.) which must accumulate raw counts and compute the ratio over the summed counts. Averaging the per-batch ratios (using NumericMetricState) is not equivalent; it is biased whenever per-batch class support varies. Accumulates confusion-matrix counts (TP, FP, FN) across an epoch using native tensors.
Implementations§
§impl ConfusionStatsState
impl ConfusionStatsState
pub fn new() -> ConfusionStatsState
pub fn new() -> ConfusionStatsState
Create a new ConfusionStatsState.
pub fn reset(&mut self)
pub fn reset(&mut self)
Reset the state.
pub fn update(
&mut self,
tp: Option<Tensor<1>>,
fp: Option<Tensor<1>>,
fn_: Option<Tensor<1>>,
sample_size: usize,
)
pub fn update( &mut self, tp: Option<Tensor<1>>, fp: Option<Tensor<1>>, fn_: Option<Tensor<1>>, sample_size: usize, )
Accumulate running totals and capture the batch snapshot.
pub fn compute_update(
&mut self,
class_reduction: ClassReduction,
format: FormatOptions,
compute_fn: impl Fn(Option<Tensor<1>>, Option<Tensor<1>>, Option<Tensor<1>>) -> Tensor<1>,
) -> Result<SerializedEntry, TensorReadError>
pub fn compute_update( &mut self, class_reduction: ClassReduction, format: FormatOptions, compute_fn: impl Fn(Option<Tensor<1>>, Option<Tensor<1>>, Option<Tensor<1>>) -> Tensor<1>, ) -> Result<SerializedEntry, TensorReadError>
Compute the batch-level value and the running epoch-level value (from all accumulated counts)
§Errors
Returns a TensorReadError if the computed metric tensors cannot be read back.
pub fn compute_final(&mut self, format: FormatOptions) -> SerializedEntry
pub fn compute_final(&mut self, format: FormatOptions) -> SerializedEntry
Compute the final metric for the accumulated global state.
pub fn current_value(&self) -> Option<NumericEntry>
pub fn current_value(&self) -> Option<NumericEntry>
Get the current batch value.
pub fn running_value(&self) -> Option<NumericEntry>
pub fn running_value(&self) -> Option<NumericEntry>
Get the running aggregated value.
pub fn final_value(&self) -> NumericEntry
pub fn final_value(&self) -> NumericEntry
Get the final value of the metric.
Trait Implementations§
§impl Clone for ConfusionStatsState
impl Clone for ConfusionStatsState
§fn clone(&self) -> ConfusionStatsState
fn clone(&self) -> ConfusionStatsState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Default for ConfusionStatsState
impl Default for ConfusionStatsState
§fn default() -> ConfusionStatsState
fn default() -> ConfusionStatsState
Auto Trait Implementations§
impl Freeze for ConfusionStatsState
impl RefUnwindSafe for ConfusionStatsState
impl Send for ConfusionStatsState
impl Sync for ConfusionStatsState
impl Unpin for ConfusionStatsState
impl UnsafeUnpin for ConfusionStatsState
impl UnwindSafe for ConfusionStatsState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<K, Q> Comparable<Q> for K
impl<K, Q> Comparable<Q> for K
§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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 more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().