/** * Variational Bayesian estimation of a Gaussian mixture, following the update * equations of sklearn.mixture.BayesianGaussianMixture (Bishop, PRML ch. 10.2): * * - weights carry a Dirichlet prior ('dirichletDistribution') or a * stick-breaking Dirichlet-process prior ('dirichletProcess'), updated with * digamma expectations; * - each component's mean/precision carries a Gaussian-Wishart prior updated * from weighted sufficient statistics; * - the E-step uses the expected log-likelihood (digamma-corrected Gaussian * densities), and convergence is declared when the change in the variational * lower bound falls below `tol`. * * covarianceType 'full' and 'diag' are implemented; 'tied' and 'spherical' * throw a clear not-implemented error. */ import { ClusterBase } from '../base/cluster'; import { Params } from '../base/estimator'; export type BayesianCovarianceType = 'full' | 'diag'; export type WeightConcentrationPriorType = 'dirichletProcess' | 'dirichletDistribution'; export interface BayesianGaussianMixtureProps { /** number of mixture components; with a DP prior extra ones shrink to ~0 weight (default 1) */ nComponents?: number; /** covariance parametrization: 'full' | 'diag' (default 'full') */ covarianceType?: BayesianCovarianceType; /** convergence threshold on the lower-bound change (default 1e-3) */ tol?: number; /** non-negative regularization added to covariance diagonals (default 1e-6) */ regCovar?: number; /** maximum number of variational iterations (default 100) */ maxIter?: number; /** number of restarts; the run with the best lower bound wins (default 1) */ nInit?: number; /** responsibility initialization: 'kmeans' | 'random' (default 'kmeans') */ initParams?: 'kmeans' | 'random'; /** seed for reproducible initialization */ randomState?: number; /** prior family on the weights (default 'dirichletProcess') */ weightConcentrationPriorType?: WeightConcentrationPriorType; /** Dirichlet/stick-breaking concentration; default 1 / nComponents */ weightConcentrationPrior?: number; /** precision prior on the mean distributions (default 1) */ meanPrecisionPrior?: number; /** prior on the mean distributions (default: column means of X) */ meanPrior?: number[]; /** Wishart degrees-of-freedom prior; must exceed nFeatures − 1 (default nFeatures) */ degreesOfFreedomPrior?: number; /** covariance prior: d×d matrix for 'full', length-d variance vector for 'diag' (default: empirical) */ covariancePrior?: number[][] | number[]; } type BayesianCovariances = number[][][] | number[][]; export declare class BayesianGaussianMixture extends ClusterBase { private nComponents; private covarianceType; private tol; private regCovar; private maxIter; private nInit; private initParams; private randomState?; private weightConcentrationPriorType; private weightConcentrationPrior?; private meanPrecisionPrior?; private meanPrior; private degreesOfFreedomPrior?; private covariancePrior; private weights_; private weightConcentrationA_; private weightConcentrationB_; private meanPrecision_; private means_; private degreesOfFreedom_; private covariances_; /** whether the best run reached the `tol` criterion */ converged: boolean; /** number of variational iterations performed by the best run */ nIter: number; private lowerBound_; private lowerBoundHistory_; constructor(props?: BayesianGaussianMixtureProps); getParams(): Params; private resolvePriors; private mStep; /** E[log πₖ] under the Dirichlet / stick-breaking posterior */ private static expectedLogWeights; /** n × k matrix E[log πₖ] + E[log N(xᵢ | μₖ, Λₖ⁻¹)] */ private weightedLogProbFromState; private computeLowerBound; private runVB; fit(X: number[][]): this; /** posterior expected mixture weights (normalized) */ private static expectedWeights; private checkFitted; private fittedState; /** hard assignment: argmax of the responsibilities */ predict(X: number[][]): number[]; /** posterior probability (responsibility) of each component for each sample */ predictProba(X: number[][]): number[][]; fitPredict(X: number[][]): number[]; /** per-sample expected log-likelihood under the variational posterior */ scoreSamples(X: number[][]): number[]; /** average per-sample expected log-likelihood */ score(X: number[][]): number; getWeights(): number[] | null; getMeans(): number[][] | null; getCovariances(): BayesianCovariances | null; /** final variational lower bound (sklearn's simplified ELBO) of the best run */ getLowerBound(): number; /** lower-bound trajectory of the best run (one entry per iteration, non-decreasing) */ getLowerBoundHistory(): number[]; } export {};