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 { ... }
}
Expand description
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.
Required Associated Types
Required Methods
sourcefn model_variance(&self, mu: f64) -> f64
fn model_variance(&self, mu: f64) -> f64
The variance of the regression family.
Provided Methods
sourcefn initialize_mu(&self, y: &[f64]) -> Vec<f64>
fn initialize_mu(&self, y: &[f64]) -> Vec<f64>
Initializes the mean value.
By default the mean takes the training target values.
sourcefn compute_working_weight(&self, mu: &[f64]) -> Vec<f64>
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))
sourcefn compute_y_bar(&self, y: &[f64], mu: &[f64]) -> Vec<f64>
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)
sourcefn apply_link_func(&self, vec: Vector<f64>) -> Vector<f64>
fn apply_link_func(&self, vec: Vector<f64>) -> Vector<f64>
Applies the link function to a vector.
sourcefn apply_link_inv(&self, vec: Vector<f64>) -> Vector<f64>
fn apply_link_inv(&self, vec: Vector<f64>) -> Vector<f64>
Applies the inverse of the link function to a vector.