pub struct PPCAMix(_);Expand description
A mixture of PPCA models. Each PPCA model is associated with a prior probability expressed in log-scale. This models allows for modelling of data clustering and non-linear learning of data. However, it will use significantly more memory and is not guaranteed to converge to a global maximum.
Notes
- The list of log-weights does not need to be normalized. Normalization is carried out internally.
- Each PPCA model in the mixture might have its own state size. However, all PPCA models must have the same output space. Additionally, the set of PPCA models must be non-empty.
Implementations§
source§impl PPCAMix
impl PPCAMix
pub fn new(models: Vec<PPCAModel>, log_weights: DVector<f64>) -> PPCAMix
sourcepub fn init(n_models: usize, state_size: usize, dataset: &Dataset) -> PPCAMix
pub fn init(n_models: usize, state_size: usize, dataset: &Dataset) -> PPCAMix
Creates a new random untrained model from a given number of PPCA modes, a latent state
size, a dataset and a smoothing factor. The smoothing factor helps with overfit of rarely
occuring dimensions. If you don’t care about that, set it to 0.0.
sourcepub fn output_size(&self) -> usize
pub fn output_size(&self) -> usize
The number of features for this model.
sourcepub fn state_sizes(&self) -> Vec<usize>
pub fn state_sizes(&self) -> Vec<usize>
The number of hidden values for each PPCA model.
sourcepub fn n_parameters(&self) -> usize
pub fn n_parameters(&self) -> usize
The total number of parameters involved in training (used for information criteria).
sourcepub fn log_weights(&self) -> &DVector<f64>
pub fn log_weights(&self) -> &DVector<f64>
The log-strength (or log-a priori probablilty) for each PPCA model.
sourcepub fn weights(&self) -> DVector<f64>
pub fn weights(&self) -> DVector<f64>
The strength (or a priori probablilty) for each PPCA model.
sourcepub fn sample(&self, dataset_size: usize, mask_probability: f64) -> Dataset
pub fn sample(&self, dataset_size: usize, mask_probability: f64) -> Dataset
Sample a full dataset from the PPCA model and masks each entry according to a
Bernoulli (coin-toss) distribution of proability mask_prob of erasing the
generated value.
sourcepub fn llk_one(&self, sample: &MaskedSample) -> f64
pub fn llk_one(&self, sample: &MaskedSample) -> f64
Computes the log-likelihood for a single sample.
sourcepub fn llks(&self, dataset: &Dataset) -> DVector<f64>
pub fn llks(&self, dataset: &Dataset) -> DVector<f64>
Computes the log-likelihood for each sample in a dataset.
sourcepub fn llk(&self, dataset: &Dataset) -> f64
pub fn llk(&self, dataset: &Dataset) -> f64
Computes the total log-likelihood for a given dataset.
sourcepub fn infer_cluster(&self, dataset: &Dataset) -> DMatrix<f64>
pub fn infer_cluster(&self, dataset: &Dataset) -> DMatrix<f64>
Returns the posterior distribution (i.e., with Baye’s rule applied) for each sample in the given dataset. Each row of the matrix corresponds to a categorical distribution on the probability of a sample belonging to a particular PPCA model.
sourcepub fn infer_one(&self, sample: &MaskedSample) -> InferredMaskedMix
pub fn infer_one(&self, sample: &MaskedSample) -> InferredMaskedMix
Infers the probability distribution of a single sample.
sourcepub fn infer(&self, dataset: &Dataset) -> Vec<InferredMaskedMix>
pub fn infer(&self, dataset: &Dataset) -> Vec<InferredMaskedMix>
Infers the probability distribution of a given dataset.
sourcepub fn smooth_one(&self, sample: &MaskedSample) -> MaskedSample
pub fn smooth_one(&self, sample: &MaskedSample) -> MaskedSample
Filters a single samples, removing noise from it and inferring the missing dimensions.
sourcepub fn smooth(&self, dataset: &Dataset) -> Dataset
pub fn smooth(&self, dataset: &Dataset) -> Dataset
Filters a dataset of samples, removing noise from the extant samples and inferring the missing samples.
sourcepub fn extrapolate_one(&self, sample: &MaskedSample) -> MaskedSample
pub fn extrapolate_one(&self, sample: &MaskedSample) -> MaskedSample
Extrapolates the missing values from a sample with the most probable values.
sourcepub fn extrapolate(&self, dataset: &Dataset) -> Dataset
pub fn extrapolate(&self, dataset: &Dataset) -> Dataset
Extrapolates the missing values from a dataset with the most probable values.
sourcepub fn iterate(&self, dataset: &Dataset) -> PPCAMix
pub fn iterate(&self, dataset: &Dataset) -> PPCAMix
Makes one iteration of the EM algorithm for the PPCA mixture model over an observed dataset, returning a improved model. The log-likelihood will always increase for the returned model.
sourcepub fn iterate_with_prior(&self, dataset: &Dataset, prior: &Prior) -> PPCAMix
pub fn iterate_with_prior(&self, dataset: &Dataset, prior: &Prior) -> PPCAMix
Makes one iteration of the EM algorithm for the PPCA mixture over an observe dataset, using a supplied PPCA prior (same for all constituent PPCA models) and returning the improved model. This method will not necessarily increase the log-likelihood of the returned model, but it will return an improved maximum a posteriori (MAP) estimate of the PPCA model according to the supplied prior.
sourcepub fn to_canonical(&self) -> PPCAMix
pub fn to_canonical(&self) -> PPCAMix
Maps PPCAModel::to_canonical for each constituent model.
Trait Implementations§
source§impl<'de> Deserialize<'de> for PPCAMix
impl<'de> Deserialize<'de> for PPCAMix
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl RefUnwindSafe for PPCAMix
impl Send for PPCAMix
impl Sync for PPCAMix
impl Unpin for PPCAMix
impl UnwindSafe for PPCAMix
Blanket Implementations§
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.