pub struct VariationalGaussianMixture { /* private fields */ }Expand description
Variational Bayes Gaussian Mixture Model fitter (VBEM / VBGMM).
The algorithm performs coordinate-ascent variational inference on the mean-field factorisation
q(pi, mu, z) = q(pi) * prod_k q(mu_k) * prod_n q(z_n)updating the Dirichlet posterior q(pi), Gaussian posteriors q(mu_k), and
categorical posteriors q(z_n) until the ELBO converges.
§Example
use tensorlogic_quantrs_hooks::vmp::{VariationalGaussianMixture, VgmmConfig};
let config = VgmmConfig::new(2)
.with_prior(0.0, 1e-3, 1.0)
.with_observation_precision(1.0)
.with_limits(100, 1e-6)
.with_seed(42);
let vgmm = VariationalGaussianMixture::new(config).unwrap();
let data = vec![0.0, 0.1, 0.2, 10.0, 10.1, 10.2];
let result = vgmm.fit(&data).unwrap();
assert!(result.converged);Implementations§
Source§impl VariationalGaussianMixture
impl VariationalGaussianMixture
Sourcepub fn new(config: VgmmConfig) -> Result<Self>
pub fn new(config: VgmmConfig) -> Result<Self>
Construct a new fitter, validating the config immediately.
Sourcepub fn fit(&self, data: &[f64]) -> Result<VgmmResult>
pub fn fit(&self, data: &[f64]) -> Result<VgmmResult>
Run VBEM on data and return the variational posterior.
§Errors
PgmError::InvalidDistributionifdatais empty or contains non-finite values.PgmError::ConvergenceFailureif the ELBO decreases by more thanconfig.divergence_tolerancein a single iteration (numerical breakdown).
Trait Implementations§
Source§impl Clone for VariationalGaussianMixture
impl Clone for VariationalGaussianMixture
Source§fn clone(&self) -> VariationalGaussianMixture
fn clone(&self) -> VariationalGaussianMixture
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for VariationalGaussianMixture
impl RefUnwindSafe for VariationalGaussianMixture
impl Send for VariationalGaussianMixture
impl Sync for VariationalGaussianMixture
impl Unpin for VariationalGaussianMixture
impl UnsafeUnpin for VariationalGaussianMixture
impl UnwindSafe for VariationalGaussianMixture
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
Converts
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>
Converts
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
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.