-
Notifications
You must be signed in to change notification settings - Fork 149
GMM CovOption redesign #153
Description
After looking at the sklearn code and seeing the huge number of possible places that CovOption can come into play, I'd like to propose a redesign of the way we handle various CovOption values.
The basic idea is that this will let us expand the types of CovOption values that we have without changing the match statements, making our API more resilient and allowing other library authors to pass their own values without necessarily needing to have their changes approved and incorporated upstream.
Trait
Create a trait that encompasses the few methods that involve CovOption. This should be something like:
pub trait CovOption {
/// Initializes the values for GMM, replaces gmm.rs:81
fn initial_values(inputs: &Matrix<f64>) -> Matrix<f64>;
/// Compute the covariance, replaces gmm.rs:334
fn compute_cov(diff: Matrix<f64>, weight: f64);
}Structs
Create a struct for each variant of our current enum. The code for this should be pretty obvious so I won't repeat it here.
GaussianMixtureModel
Similar to now, it will take a struct S where S: CovOption.