Module rusty_machine::learning::glm [] [src]

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

Bernoulli

The Bernoulli regression family.

Binomial

The Binomial regression family.

GenLinearModel

The Generalized Linear Model

Identity

The Identity link function.

Log

The log link function.

Logit

The Logit link function.

Normal

The Normal regression family.

Poisson

The Poisson regression family.

Traits

Criterion

The criterion for the Generalized Linear Model.

LinkFunc

Link functions.