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

Any prediction made by this model will have the value of c

Methods

impl<I> Constant<I>
[src]

Creates a new Constant from a f64

Trait Implementations

impl<Input: Debug> Debug for Constant<Input>
[src]

Formats the value using the given formatter.

impl<Input: Default> Default for Constant<Input>
[src]

Returns the "default value" for a type. Read more

impl<Input: Decodable> Decodable for Constant<Input>
[src]

impl<Input: Encodable> Encodable for Constant<Input>
[src]

impl<I> Clone for Constant<I>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<I> Model for Constant<I>
[src]

Input features

Predicts a target for the inputs based on the internal coefficents

The number of internal coefficents this model depends on

Value predict derived by the n-th coefficent at input

Mutable reference to the n-th coefficent