Trait rusty_machine::learning::glm::Criterion
[−]
[src]
pub trait Criterion { type Link: LinkFunc; fn model_variance(&self, mu: f64) -> f64; fn initialize_mu(&self, y: &[f64]) -> Vec<f64> { ... } fn compute_working_weight(&self, mu: &[f64]) -> Vec<f64> { ... } fn compute_y_bar(&self, y: &[f64], mu: &[f64]) -> Vec<f64> { ... } fn apply_link_func(&self, vec: Vector<f64>) -> Vector<f64> { ... } fn apply_link_inv(&self, vec: Vector<f64>) -> Vector<f64> { ... } fn link_grad(&self, mu: f64) -> f64 { ... } }
The criterion for the Generalized Linear Model.
This trait specifies a Link function and requires a model variance to be specified. The model variance must be defined to specify the regression family. The other functions need not be specified but can be used to control optimization.
Associated Types
Required Methods
fn model_variance(&self, mu: f64) -> f64
The variance of the regression family.
Provided Methods
fn initialize_mu(&self, y: &[f64]) -> Vec<f64>
Initializes the mean value.
By default the mean takes the training target values.
fn compute_working_weight(&self, mu: &[f64]) -> Vec<f64>
Computes the working weights that make up the diagonal
of the W
matrix used in the iterative reweighted least squares
algorithm.
This is equal to:
1 / (Var(u) * g'(u) * g'(u))
fn compute_y_bar(&self, y: &[f64], mu: &[f64]) -> Vec<f64>
Computes the adjustment to the fitted values used during fitting.
This is equal to:
g`(u) * (y - u)
fn apply_link_func(&self, vec: Vector<f64>) -> Vector<f64>
Applies the link function to a vector.
fn apply_link_inv(&self, vec: Vector<f64>) -> Vector<f64>
Applies the inverse of the link function to a vector.
fn link_grad(&self, mu: f64) -> f64
Computes the gradient of the link function.