pub struct ClassificationMetrics {
pub total: usize,
pub correct: usize,
pub class_tp: HashMap<String, usize>,
pub class_fp: HashMap<String, usize>,
pub class_fn: HashMap<String, usize>,
pub class_support: HashMap<String, usize>,
}Expand description
Metrics for text classification tasks.
Supports multi-class classification with macro/micro/weighted averaging.
Fields§
§total: usizeTotal number of examples
correct: usizeNumber of correct predictions
class_tp: HashMap<String, usize>Per-class true positives
class_fp: HashMap<String, usize>Per-class false positives
class_fn: HashMap<String, usize>Per-class false negatives
class_support: HashMap<String, usize>Per-class support (total examples per class)
Implementations§
Source§impl ClassificationMetrics
impl ClassificationMetrics
Sourcepub fn macro_precision(&self) -> f64
pub fn macro_precision(&self) -> f64
Macro-averaged precision (unweighted average across classes).
Sourcepub fn macro_recall(&self) -> f64
pub fn macro_recall(&self) -> f64
Macro-averaged recall (unweighted average across classes).
Sourcepub fn micro_precision(&self) -> f64
pub fn micro_precision(&self) -> f64
Micro-averaged precision (aggregate TP/FP across classes).
Sourcepub fn micro_recall(&self) -> f64
pub fn micro_recall(&self) -> f64
Micro-averaged recall (aggregate TP/FN across classes).
Sourcepub fn weighted_f1(&self) -> f64
pub fn weighted_f1(&self) -> f64
Weighted F1 score (weighted by class support).
Sourcepub fn class_precision(&self, class: &str) -> f64
pub fn class_precision(&self, class: &str) -> f64
Precision for a specific class.
Sourcepub fn class_recall(&self, class: &str) -> f64
pub fn class_recall(&self, class: &str) -> f64
Recall for a specific class.
Trait Implementations§
Source§impl Clone for ClassificationMetrics
impl Clone for ClassificationMetrics
Source§fn clone(&self) -> ClassificationMetrics
fn clone(&self) -> ClassificationMetrics
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 moreSource§impl Debug for ClassificationMetrics
impl Debug for ClassificationMetrics
Source§impl Default for ClassificationMetrics
impl Default for ClassificationMetrics
Source§fn default() -> ClassificationMetrics
fn default() -> ClassificationMetrics
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ClassificationMetrics
impl RefUnwindSafe for ClassificationMetrics
impl Send for ClassificationMetrics
impl Sync for ClassificationMetrics
impl Unpin for ClassificationMetrics
impl UnsafeUnpin for ClassificationMetrics
impl UnwindSafe for ClassificationMetrics
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more