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

pub struct LinRegressor { /* fields omitted */ }

Linear Regression Model.

Contains option for optimized parameter.

Methods

impl LinRegressor
[src]

Get the parameters from the model.

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

impl LinRegressor
[src]

Train the linear regressor using Gradient Descent.

Examples

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

let inputs = Matrix::new(4,1,vec![1.0,3.0,5.0,7.0]);
let targets = Vector::new(vec![1.,5.,9.,13.]);

let mut lin_mod = LinRegressor::default();

// Train the model
lin_mod.train_with_optimization(&inputs, &targets);

// Now we'll predict a new point
let new_point = Matrix::new(1,1,vec![10.]);
let _ = lin_mod.predict(&new_point).unwrap();

Trait Implementations

impl Debug for LinRegressor
[src]

Formats the value using the given formatter.

impl Default for LinRegressor
[src]

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

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

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;
use rusty_machine::linalg::Vector;
use rusty_machine::learning::SupModel;

let mut lin_mod = LinRegressor::default();
let inputs = Matrix::new(3,1, vec![2.0, 3.0, 4.0]);
let targets = Vector::new(vec![5.0, 6.0, 7.0]);

lin_mod.train(&inputs, &targets).unwrap();

Predict output value from input data.

Model must be trained before prediction can be made.

impl Optimizable for LinRegressor
[src]

The input data type to the model.

The target data type to the model.

Compute the gradient for the model.