reductionml_core/metrics/
metric.rs1use crate::{
2 types::{Label, Prediction},
3 Features,
4};
5
6pub trait Metric {
7 fn add_point(&mut self, features: &Features, label: &Label, prediction: &Prediction);
8 fn get_value(&self) -> MetricValue;
9 fn get_name(&self) -> String;
10}
11
12pub enum MetricValue {
13 Bool(bool),
14 Float(f32),
15 Int(i32),
16 String(String),
17}
18
19impl ToString for MetricValue {
20 fn to_string(&self) -> String {
21 match self {
22 MetricValue::Bool(b) => b.to_string(),
23 MetricValue::Float(f) => f.to_string(),
24 MetricValue::Int(i) => i.to_string(),
25 MetricValue::String(s) => s.clone(),
26 }
27 }
28}