pub struct PPCAModel(/* private fields */);Expand description
A PPCA model which can infer missing values.
Each sample for this model behaves according to the following statistical latent variable model.
x ~ N(0; I(nxn))
y = C * x + y0 + noise
noise ~ N(0; sigma ^ 2 * I(mxm))Here, x is the latent state, y is the observed sample, that is an affine
transformation of the hidden state contaminated by isotropic noise.
§Note
All arrays involved have to be of data type float64.
Implementations§
Source§impl PPCAModel
impl PPCAModel
pub fn new( isotropic_noise: f64, transform: DMatrix<f64>, mean: DVector<f64>, ) -> PPCAModel
Sourcepub fn init(state_size: usize, dataset: &Dataset) -> PPCAModel
pub fn init(state_size: usize, dataset: &Dataset) -> PPCAModel
Creates a new random untrained model from a given latent state size and a dataset.
Sourcepub fn mean(&self) -> &DVector<f64>
pub fn mean(&self) -> &DVector<f64>
Then center of mass of the distribution in the output space.
Sourcepub fn isotropic_noise(&self) -> f64
pub fn isotropic_noise(&self) -> f64
The standard deviation of the noise in the output space.
Sourcepub fn transform(&self) -> &DMatrix<f64>
pub fn transform(&self) -> &DMatrix<f64>
The linear transformation from hidden state space to output space.
Sourcepub fn output_size(&self) -> usize
pub fn output_size(&self) -> usize
The number of features for this model.
Sourcepub fn state_size(&self) -> usize
pub fn state_size(&self) -> usize
The number of hidden values for this model.
Sourcepub fn uninferred(&self) -> InferredMasked
pub fn uninferred(&self) -> InferredMasked
Creates a zeroed InferredMasked struct that is compatible with this 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 singular_values(&self) -> DVector<f64>
pub fn singular_values(&self) -> DVector<f64>
The relative strength of each hidden variable on the output. This is equivalent to the eigenvalues in the standard PCA.
Sourcepub fn llk_one(&self, sample: &MaskedSample) -> f64
pub fn llk_one(&self, sample: &MaskedSample) -> f64
Compute the log-likelihood of a single sample.
Sourcepub fn llks(&self, dataset: &Dataset) -> DVector<f64>
pub fn llks(&self, dataset: &Dataset) -> DVector<f64>
Compute the log-likelihood for each sample in a given dataset.
Sourcepub fn sample_one(&self, mask_prob: f64) -> MaskedSample
pub fn sample_one(&self, mask_prob: f64) -> MaskedSample
Sample a single sample from the PPCA model and masks each entry according to a
Bernoulli (coin-toss) distribution of probability mask_prob of erasing the
generated value.
Sourcepub fn sample(&self, dataset_size: usize, mask_prob: f64) -> Dataset
pub fn sample(&self, dataset_size: usize, mask_prob: f64) -> Dataset
Sample a full dataset from the PPCA model and masks each entry according to a
Bernoulli (coin-toss) distribution of probability mask_prob of erasing the
generated value.
Sourcepub fn infer_one(&self, sample: &MaskedSample) -> InferredMasked
pub fn infer_one(&self, sample: &MaskedSample) -> InferredMasked
Infers the hidden components for one single sample. Use this method for fine-grain control on the properties you want to extract from the model.
Sourcepub fn inferred_one(
&self,
state: DVector<f64>,
covariance: DMatrix<f64>,
) -> InferredMasked
pub fn inferred_one( &self, state: DVector<f64>, covariance: DMatrix<f64>, ) -> InferredMasked
Builds a new InferredMasked from the raw values.
Sourcepub fn infer(&self, dataset: &Dataset) -> Vec<InferredMasked>
pub fn infer(&self, dataset: &Dataset) -> Vec<InferredMasked>
Infers the hidden components for each sample in the dataset. Use this method for fine-grain control on the properties you want to extract from the model.
Sourcepub fn smooth_one(&self, sample: &MaskedSample) -> MaskedSample
pub fn smooth_one(&self, sample: &MaskedSample) -> MaskedSample
Filters a single samples, removing noise from the extant samples and inferring the missing samples.
Sourcepub fn smooth(&self, dataset: &Dataset) -> Dataset
pub fn smooth(&self, dataset: &Dataset) -> Dataset
Filters each sample of a given dataset, 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 with the most probable values for a single sample. This method does not alter the extant values.
Sourcepub fn extrapolate(&self, dataset: &Dataset) -> Dataset
pub fn extrapolate(&self, dataset: &Dataset) -> Dataset
Extrapolates the missing values with the most probable values for a full dataset. This method does not alter the extant values.
Sourcepub fn iterate(&self, dataset: &Dataset) -> PPCAModel
pub fn iterate(&self, dataset: &Dataset) -> PPCAModel
Makes one iteration of the EM algorithm for the PPCA over an observed dataset, returning the improved model. The log-likelihood will always increase for the returned model.
Sourcepub fn iterate_with_prior(&self, dataset: &Dataset, prior: &Prior) -> PPCAModel
pub fn iterate_with_prior(&self, dataset: &Dataset, prior: &Prior) -> PPCAModel
Makes one iteration of the EM algorithm for the PPCA over an observed dataset, using a supplied PPCA prior 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) -> PPCAModel
pub fn to_canonical(&self) -> PPCAModel
Returns a canonical version of this model. This does not alter the log-probability function nor the quality of the training. All it does is to transform the hidden variables.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PPCAModel
impl<'de> Deserialize<'de> for PPCAModel
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 Freeze for PPCAModel
impl RefUnwindSafe for PPCAModel
impl Send for PPCAModel
impl Sync for PPCAModel
impl Unpin for PPCAModel
impl UnwindSafe for PPCAModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§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).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.