import { IClusterModel, IDataset, IEmOptions } from '../types'; /** * Expectation maximization using a gaussian mixture model * This class only holds the internal state of the * optimized gaussian mixture model (GMM) used for each clustering model. * * For instance: * * ```ts * const dataset: IDataset = { * 'points': [ * [1.1,1], * [1,2], * [2,2], * [2,1], * [15,15], * [15,16], * ], * 'label':'test', * }; * const opts: IEmOptions = { * 'clusterQt':2, * 'maxEpochs':1000, * 'threshold': 2e-16 * } * const test = new ExpMax(dataset, opts); * const chose = test.train() * console.log(chose); * ``` * * This program will output the likelihood of your data point belonging to each * distribution. * * Please mind that, in this class, the dataset is mutable for computation purpose. * Indeed, we don't want to fit a new, randomly generated GMM for * every slight change in our dataset. */ export default class ExpMax { /** * Clusters */ private _clusters; /** * Data */ private _dataset; /** * Vector space dimension */ private _vectorSpaceDim; /** * Options */ private _opts; constructor(dataset: IDataset, options: IEmOptions); /** * Update dataset * Mutates internal state * @param newDataset: IDataset * @returns IClusterModel[] | error */ update(newDataset: IDataset): IClusterModel[]; /** * Em Algorithm * @returns IClusterModel[] */ train(): IClusterModel[]; }