DocumentationClassesGaussianMixture

Class: GaussianMixture

Gaussian Mixture.

Representation of a Gaussian mixture model probability distribution. This class allows to estimate the parameters of a Gaussian mixture distribution.

Read more in the User Guide.

Python Reference

Constructors

new GaussianMixture()

new GaussianMixture(opts?): GaussianMixture

Parameters

ParameterTypeDescription
opts?object-
opts.covariance_type?"full" | "tied" | "diag" | "spherical"String describing the type of covariance parameters to use. Must be one of:
opts.init_params?"k-means++" | "random" | "kmeans" | "random_from_data"The method used to initialize the weights, the means and the precisions. String must be one of:
opts.max_iter?numberThe number of EM iterations to perform.
opts.means_init?ArrayLike[]The user-provided initial means, If it is undefined, means are initialized using the init_params method.
opts.n_components?numberThe number of mixture components.
opts.n_init?numberThe number of initializations to perform. The best results are kept.
opts.precisions_init?ArrayLikeThe user-provided initial precisions (inverse of the covariance matrices). If it is undefined, precisions are initialized using the ‘init_params’ method. The shape depends on ‘covariance_type’:
opts.random_state?numberControls the random seed given to the method chosen to initialize the parameters (see init_params). In addition, it controls the generation of random samples from the fitted distribution (see the method sample). Pass an int for reproducible output across multiple function calls. See Glossary.
opts.reg_covar?numberNon-negative regularization added to the diagonal of covariance. Allows to assure that the covariance matrices are all positive.
opts.tol?numberThe convergence threshold. EM iterations will stop when the lower bound average gain is below this threshold.
opts.verbose?numberEnable verbose output. If 1 then it prints the current initialization and each iteration step. If greater than 1 then it prints also the log probability and the time needed for each step.
opts.verbose_interval?numberNumber of iteration done before the next print.
opts.warm_start?booleanIf ‘warm_start’ is true, the solution of the last fitting is used as initialization for the next call of fit(). This can speed up convergence when fit is called several times on similar problems. In that case, ‘n_init’ is ignored and only a single initialization occurs upon the first call. See the Glossary.
opts.weights_init?ArrayLikeThe user-provided initial weights. If it is undefined, weights are initialized using the init_params method.

Returns GaussianMixture

Defined in generated/mixture/GaussianMixture.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/mixture/GaussianMixture.ts:23
_isInitializedbooleanfalsegenerated/mixture/GaussianMixture.ts:22
_pyPythonBridgeundefinedgenerated/mixture/GaussianMixture.ts:21
idstringundefinedgenerated/mixture/GaussianMixture.ts:18
optsanyundefinedgenerated/mixture/GaussianMixture.ts:19

Accessors

converged_

Get Signature

get converged_(): Promise<boolean>

True when convergence of the best fit of EM was reached, false otherwise.

Returns Promise<boolean>

Defined in generated/mixture/GaussianMixture.ts:663


covariances_

Get Signature

get covariances_(): Promise<ArrayLike>

The covariance of each mixture component. The shape depends on covariance_type:

Returns Promise<ArrayLike>

Defined in generated/mixture/GaussianMixture.ts:588


feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

Names of features seen during fit. Defined only when X has feature names that are all strings.

Returns Promise<ArrayLike>

Defined in generated/mixture/GaussianMixture.ts:763


lower_bound_

Get Signature

get lower_bound_(): Promise<number>

Lower bound value on the log-likelihood (of the training data with respect to the model) of the best fit of EM.

Returns Promise<number>

Defined in generated/mixture/GaussianMixture.ts:713


means_

Get Signature

get means_(): Promise<ArrayLike[]>

The mean of each mixture component.

Returns Promise<ArrayLike[]>

Defined in generated/mixture/GaussianMixture.ts:563


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/mixture/GaussianMixture.ts:738


n_iter_

Get Signature

get n_iter_(): Promise<number>

Number of step used by the best fit of EM to reach the convergence.

Returns Promise<number>

Defined in generated/mixture/GaussianMixture.ts:688


precisions_

Get Signature

get precisions_(): Promise<ArrayLike>

The precision matrices for each component in the mixture. A precision matrix is the inverse of a covariance matrix. A covariance matrix is symmetric positive definite so the mixture of Gaussian can be equivalently parameterized by the precision matrices. Storing the precision matrices instead of the covariance matrices makes it more efficient to compute the log-likelihood of new samples at test time. The shape depends on covariance_type:

Returns Promise<ArrayLike>

Defined in generated/mixture/GaussianMixture.ts:613


precisions_cholesky_

Get Signature

get precisions_cholesky_(): Promise<ArrayLike>

The cholesky decomposition of the precision matrices of each mixture component. A precision matrix is the inverse of a covariance matrix. A covariance matrix is symmetric positive definite so the mixture of Gaussian can be equivalently parameterized by the precision matrices. Storing the precision matrices instead of the covariance matrices makes it more efficient to compute the log-likelihood of new samples at test time. The shape depends on covariance_type:

Returns Promise<ArrayLike>

Defined in generated/mixture/GaussianMixture.ts:638


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/mixture/GaussianMixture.ts:120


weights_

Get Signature

get weights_(): Promise<ArrayLike>

The weights of each mixture components.

Returns Promise<ArrayLike>

Defined in generated/mixture/GaussianMixture.ts:538

Methods

aic()

aic(opts): Promise<number>

Akaike information criterion for the current model on the input X.

You can refer to this mathematical section for more details regarding the formulation of the AIC used.

Parameters

ParameterTypeDescription
optsobject-
opts.X?any[]The input samples.

Returns Promise<number>

Defined in generated/mixture/GaussianMixture.ts:191


bic()

bic(opts): Promise<number>

Bayesian information criterion for the current model on the input X.

You can refer to this mathematical section for more details regarding the formulation of the BIC used.

Parameters

ParameterTypeDescription
optsobject-
opts.X?any[]The input samples.

Returns Promise<number>

Defined in generated/mixture/GaussianMixture.ts:225


dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Returns Promise<void>

Defined in generated/mixture/GaussianMixture.ts:172


fit()

fit(opts): Promise<any>

Estimate model parameters with the EM algorithm.

The method fits the model n_init times and sets the parameters with which the model has the largest likelihood or lower bound. Within each trial, the method iterates between E-step and M-step for max_iter times until the change of likelihood or lower bound is less than tol, otherwise, a ConvergenceWarning is raised. If warm_start is true, then n_init is ignored and a single initialization is performed upon the first call. Upon consecutive calls, training starts where it left off.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]List of n_features-dimensional data points. Each row corresponds to a single data point.
opts.y?anyNot used, present for API consistency by convention.

Returns Promise<any>

Defined in generated/mixture/GaussianMixture.ts:259


fit_predict()

fit_predict(opts): Promise<any>

Estimate model parameters using X and predict the labels for X.

The method fits the model n_init times and sets the parameters with which the model has the largest likelihood or lower bound. Within each trial, the method iterates between E-step and M-step for max_iter times until the change of likelihood or lower bound is less than tol, otherwise, a ConvergenceWarning is raised. After fitting, it predicts the most probable label for the input data points.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]List of n_features-dimensional data points. Each row corresponds to a single data point.
opts.y?anyNot used, present for API consistency by convention.

Returns Promise<any>

Defined in generated/mixture/GaussianMixture.ts:298


get_metadata_routing()

get_metadata_routing(opts): Promise<any>

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Parameters

ParameterTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns Promise<any>

Defined in generated/mixture/GaussianMixture.ts:337


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/mixture/GaussianMixture.ts:133


predict()

predict(opts): Promise<any>

Predict the labels for the data samples in X using trained model.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]List of n_features-dimensional data points. Each row corresponds to a single data point.

Returns Promise<any>

Defined in generated/mixture/GaussianMixture.ts:371


predict_proba()

predict_proba(opts): Promise<any>

Evaluate the components’ density for each sample.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]List of n_features-dimensional data points. Each row corresponds to a single data point.

Returns Promise<any>

Defined in generated/mixture/GaussianMixture.ts:403


sample()

sample(opts): Promise<any>

Generate random samples from the fitted Gaussian distribution.

Parameters

ParameterTypeDescription
optsobject-
opts.n_samples?numberNumber of samples to generate.

Returns Promise<any>

Defined in generated/mixture/GaussianMixture.ts:435


score()

score(opts): Promise<number>

Compute the per-sample average log-likelihood of the given data X.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]List of n_features-dimensional data points. Each row corresponds to a single data point.
opts.y?anyNot used, present for API consistency by convention.

Returns Promise<number>

Defined in generated/mixture/GaussianMixture.ts:469


score_samples()

score_samples(opts): Promise<any>

Compute the log-likelihood of each sample.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]List of n_features-dimensional data points. Each row corresponds to a single data point.

Returns Promise<any>

Defined in generated/mixture/GaussianMixture.ts:506