Struct vikos::model::Constant
[−]
[src]
pub struct Constant<Input> { pub c: f64, // some fields omitted }
Models the target as a constant c
This model predicts a number. The cost function used during training decides whether this number is a mean, median, or something else.
Examples
Estimate mean
use vikos::model::Constant; use vikos::cost::LeastSquares; use vikos::teacher::GradientDescentAl; use vikos::learn_history; let features = (); let history = [1f64, 3.0, 4.0, 7.0, 8.0, 11.0, 29.0]; //mean is 9 let cost = LeastSquares{}; let mut model = Constant::new(0.0); let teacher = GradientDescentAl{ l0 : 0.3, t : 4.0 }; learn_history(&teacher, &cost, &mut model, history.iter().cycle().map(|&y|((),y)).take(100)); println!("{}", model.c);
Fields
c: f64
Any prediction made by this model will have the value of c
Methods
impl<I> Constant<I>
[src]
Trait Implementations
impl<Input: Debug> Debug for Constant<Input>
[src]
impl<Input: Default> Default for Constant<Input>
[src]
impl<Input: Decodable> Decodable for Constant<Input>
[src]
impl<Input: Encodable> Encodable for Constant<Input>
[src]
impl<I> Clone for Constant<I>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<I> Model for Constant<I>
[src]
type Input = I
Input features
fn predict(&self, _: &I) -> f64
Predicts a target for the inputs based on the internal coefficents
fn num_coefficents(&self) -> usize
The number of internal coefficents this model depends on
fn gradient(&self, coefficent: usize, _: &I) -> f64
Value predict derived by the n-th coefficent
at input
fn coefficent(&mut self, coefficent: usize) -> &mut f64
Mutable reference to the n-th coefficent