Module rusty_machine::learning::glm
source · [−]Expand description
Generalized Linear Model module
This model is likely to undergo changes in the near future. These changes will improve the learning algorithm.
Contains implemention of generalized linear models using iteratively reweighted least squares.
The model will automatically add the intercept term to the input data.
Usage
use rusty_machine::learning::glm::{GenLinearModel, Bernoulli};
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![0.,0.,1.,1.]);
// Construct a GLM with a Bernoulli distribution
// This is equivalent to a logistic regression model.
let mut log_mod = GenLinearModel::new(Bernoulli);
// Train the model
log_mod.train(&inputs, &targets).unwrap();
// Now we'll predict a new point
let new_point = Matrix::new(1,1,vec![10.]);
let output = log_mod.predict(&new_point).unwrap();
// Hopefully we classified our new point correctly!
assert!(output[0] > 0.5, "Our classifier isn't very good!");
Structs
The Bernoulli regression family.
The Binomial regression family.
The Generalized Linear Model
The Identity link function.
The log link function.
The Logit link function.
The Normal regression family.
The Poisson regression family.