pub trait Distance {
// Required method
fn err_buf(&self, rhs: &Self) -> Vec<f64>;
// Provided methods
fn square_err(&self, rhs: &Self) -> f64 { ... }
fn l0_norm(&self, rhs: &Self) -> f64 { ... }
fn l1_norm(&self, rhs: &Self) -> f64 { ... }
fn l2_norm(&self, rhs: &Self) -> f64 { ... }
fn lp_norm(&self, rhs: &Self, p: i32) -> f64 { ... }
}Expand description
Be able to calculate the distance between two instances.
Each data number has the same weight by default, but you can change it by
implementing Distance::err_buf().
Required Methods§
Provided Methods§
sourcefn square_err(&self, rhs: &Self) -> f64
fn square_err(&self, rhs: &Self) -> f64
Calculate the square error.
Object Safety§
This trait is not object safe.