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

pub struct LinRegressor {
    // some fields omitted
}

Linear Regression Model.

Contains option for optimized parameter.

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();

fn parameters(&self) -> Option<Vector<f64>>

Get the parameters from the model.

Returns an option that is None if the model has not been trained.

Trait Implementations

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

fn train(&mut self, inputs: &Matrix<f64>, targets: &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 inputs = Matrix::new(3,2, vec![1.0, 2.0, 1.0, 3.0, 1.0, 4.0]);
let targets = Vector::new(vec![5.0, 6.0, 7.0]);

lin_mod.train(&inputs, &targets);

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

Predict output value from input data.

Model must be trained before prediction can be made.