Trait Metric
pub trait Metric: Send + Sync {
type Input;
// Required methods
fn name(&self) -> String;
fn update(
&mut self,
item: &Self::Input,
metadata: &MetricMetadata,
) -> MetricEntry;
fn clear(&mut self);
}
Expand description
Metric trait.
§Notes
Implementations should define their own input type only used by the metric. This is important since some conflict may happen when the model output is adapted for each metric’s input type.
Required Associated Types§
type Input
type Input
The input type of the metric.
Required Methods§
fn name(&self) -> String
fn name(&self) -> String
The parameterized name of the metric.
This should be unique, so avoid using short generic names, prefer using the long name.
For a metric that can exist at different parameters (e.g., top-k accuracy for different values of k), the name should be unique for each instance.
fn update(
&mut self,
item: &Self::Input,
metadata: &MetricMetadata,
) -> MetricEntry
fn update( &mut self, item: &Self::Input, metadata: &MetricMetadata, ) -> MetricEntry
Update the metric state and returns the current metric entry.
fn clear(&mut self)
fn clear(&mut self)
Clear the metric state.