Trait Metric
pub trait Metric:
Send
+ Sync
+ Clone {
type Input;
// Required methods
fn name(&self) -> Arc<String>;
fn update(
&mut self,
item: &Self::Input,
metadata: &MetricMetadata,
) -> SerializedEntry;
fn clear(&mut self);
// Provided methods
fn description(&self) -> Option<String> { ... }
fn attributes(&self) -> MetricAttributes { ... }
}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) -> Arc<String>
fn name(&self) -> Arc<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,
) -> SerializedEntry
fn update( &mut self, item: &Self::Input, metadata: &MetricMetadata, ) -> SerializedEntry
Update the metric state and returns the current metric entry.
fn clear(&mut self)
fn clear(&mut self)
Clear the metric state.
Provided Methods§
fn description(&self) -> Option<String>
fn description(&self) -> Option<String>
A short description of the metric.
fn attributes(&self) -> MetricAttributes
fn attributes(&self) -> MetricAttributes
Attributes of the metric.
By default, metrics have no attributes.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
§impl<B> Metric for AccuracyMetric<B>where
B: Backend,
impl<B> Metric for AccuracyMetric<B>where
B: Backend,
type Input = AccuracyInput<B>
§impl<B> Metric for AurocMetric<B>where
B: Backend,
impl<B> Metric for AurocMetric<B>where
B: Backend,
type Input = AurocInput<B>
§impl<B> Metric for CharErrorRate<B>where
B: Backend,
The character error rate metric implementation.
impl<B> Metric for CharErrorRate<B>where
B: Backend,
The character error rate metric implementation.