Skip to main content

entrenar/train/metrics/
trait_def.rs

1//! Core Metric trait definition
2
3use crate::Tensor;
4
5/// Trait for evaluation metrics
6pub trait Metric {
7    /// Compute the metric given predictions and targets
8    fn compute(&self, predictions: &Tensor, targets: &Tensor) -> f32;
9
10    /// Name of the metric
11    fn name(&self) -> &str;
12
13    /// Whether higher values are better (true) or lower (false)
14    fn higher_is_better(&self) -> bool {
15        true
16    }
17}