Struct rusty_machine::learning::lin_reg::LinRegressor [] [src]

pub struct LinRegressor {
    pub b: Option<Vector<f64>>,
}

Linear Regression Model.

Contains option for optimized parameter.

Fields

b: Option<Vector<f64>>

Methods

impl LinRegressor
[src]

fn new() -> LinRegressor

Constructs untrained linear regression model.

Examples

use rusty_machine::learning::lin_reg::LinRegressor;

let mut lin_mod = LinRegressor::new();

Trait Implementations

impl SupModel<Matrix<f64>, Vector<f64>> for LinRegressor
[src]

fn train(&mut self, data: Matrix<f64>, values: Vector<f64>)

Train the linear regression model.

Takes training data and output values as input.

Examples

use rusty_machine::learning::lin_reg::LinRegressor;
use rusty_machine::linalg::matrix::Matrix;
use rusty_machine::linalg::vector::Vector;
use rusty_machine::learning::SupModel;

let mut lin_mod = LinRegressor::new();
let data = Matrix::new(3,2, vec![1.0, 2.0, 1.0, 3.0, 1.0, 4.0]);
let values = Vector::new(vec![5.0, 6.0, 7.0]);

lin_mod.train(data, values);

fn predict(&self, data: Matrix<f64>) -> Vector<f64>

Predict output value from input data.

Model must be trained before prediction can be made.