Model

Trait Model 

Source
pub trait Model {
    type Features;
    type Target;

    // Required methods
    fn num_coefficients(&self) -> usize;
    fn coefficient(&mut self, coefficient: usize) -> &mut f64;
    fn predict(&self, _: &Self::Features) -> Self::Target;
    fn gradient(
        &self,
        coefficient: usize,
        input: &Self::Features,
    ) -> Self::Target;
}
Expand description

A parameterized expert algorithm

Implementations of this trait can be found in models

Required Associated Types§

Source

type Features

Input from which to predict the target

Source

type Target

f64 for Regressors or binary classifiers. For multi classification an array of f64 with a dimension equal to the number of classes.

Required Methods§

Source

fn num_coefficients(&self) -> usize

The number of internal coefficients this model depends on

Source

fn coefficient(&mut self, coefficient: usize) -> &mut f64

Mutable reference to the n-th coefficient

Source

fn predict(&self, _: &Self::Features) -> Self::Target

Predicts a target for the inputs based on the internal coefficients

Source

fn gradient(&self, coefficient: usize, input: &Self::Features) -> Self::Target

Value predict derived by the n-th coefficient at input

Implementations on Foreign Types§

Source§

impl Model for f64

Source§

type Features = ()

Source§

type Target = f64

Source§

fn num_coefficients(&self) -> usize

Source§

fn coefficient(&mut self, coefficient: usize) -> &mut f64

Source§

fn predict(&self, _: &()) -> f64

Source§

fn gradient(&self, coefficient: usize, _: &()) -> f64

Implementors§

Source§

impl<T> Model for OneVsRest<T>
where T: Array, T::Element: Model<Target = f64>,

Source§

type Features = <<T as Array>::Element as Model>::Features

Source§

type Target = <T as Array>::Vector

Source§

impl<V> Model for Linear<V>
where V: Vector,

Source§

impl<V> Model for Logistic<V>
where Linear<V>: Model<Features = V, Target = f64>,

Source§

impl<V, F, Df> Model for GeneralizedLinearModel<V, F, Df>
where F: Fn(f64) -> f64, Df: Fn(f64) -> f64, Linear<V>: Model<Features = V, Target = f64>,