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 (opens in a new tab)
Constructors
constructor()
Signature
new GaussianMixture(opts?: object): GaussianMixture;
Parameters
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.covariance_type? | "full" | "tied" | "diag" | "spherical" | String describing the type of covariance parameters to use. Must be one of: Default Value 'full' |
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: Default Value 'kmeans' |
opts.max_iter? | number | The number of EM iterations to perform. Default Value 100 |
opts.means_init? | ArrayLike [] | The user-provided initial means, If it is undefined , means are initialized using the init\_params method. |
opts.n_components? | number | The number of mixture components. Default Value 1 |
opts.n_init? | number | The number of initializations to perform. The best results are kept. Default Value 1 |
opts.precisions_init? | ArrayLike | The 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? | number | Controls 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? | number | Non-negative regularization added to the diagonal of covariance. Allows to assure that the covariance matrices are all positive. Default Value 0.000001 |
opts.tol? | number | The convergence threshold. EM iterations will stop when the lower bound average gain is below this threshold. Default Value 0.001 |
opts.verbose? | number | Enable 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. Default Value 0 |
opts.verbose_interval? | number | Number of iteration done before the next print. Default Value 10 |
opts.warm_start? | boolean | If ‘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. Default Value false |
opts.weights_init? | ArrayLike | The user-provided initial weights. If it is undefined , weights are initialized using the init\_params method. |
Returns
Defined in: generated/mixture/GaussianMixture.ts:25 (opens in a new tab)
Methods
aic()
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.
Signature
aic(opts: object): Promise<number>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | any [] | The input samples. |
Returns
Promise
<number
>
Defined in: generated/mixture/GaussianMixture.ts:212 (opens in a new tab)
bic()
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.
Signature
bic(opts: object): Promise<number>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | any [] | The input samples. |
Returns
Promise
<number
>
Defined in: generated/mixture/GaussianMixture.ts:247 (opens in a new tab)
dispose()
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Signature
dispose(): Promise<void>;
Returns
Promise
<void
>
Defined in: generated/mixture/GaussianMixture.ts:193 (opens in a new tab)
fit()
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.
Signature
fit(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | List of n_features-dimensional data points. Each row corresponds to a single data point. |
opts.y? | any | Not used, present for API consistency by convention. |
Returns
Promise
<any
>
Defined in: generated/mixture/GaussianMixture.ts:282 (opens in a new tab)
fit_predict()
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.
Signature
fit_predict(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | List of n_features-dimensional data points. Each row corresponds to a single data point. |
opts.y? | any | Not used, present for API consistency by convention. |
Returns
Promise
<any
>
Defined in: generated/mixture/GaussianMixture.ts:322 (opens in a new tab)
get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Signature
get_metadata_routing(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.routing? | any | A MetadataRequest encapsulating routing information. |
Returns
Promise
<any
>
Defined in: generated/mixture/GaussianMixture.ts:362 (opens in a new tab)
init()
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Signature
init(py: PythonBridge): Promise<void>;
Parameters
Name | Type |
---|---|
py | PythonBridge |
Returns
Promise
<void
>
Defined in: generated/mixture/GaussianMixture.ts:133 (opens in a new tab)
predict()
Predict the labels for the data samples in X using trained model.
Signature
predict(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
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:397 (opens in a new tab)
predict_proba()
Evaluate the components’ density for each sample.
Signature
predict_proba(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
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:430 (opens in a new tab)
sample()
Generate random samples from the fitted Gaussian distribution.
Signature
sample(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.n_samples? | number | Number of samples to generate. Default Value 1 |
Returns
Promise
<any
>
Defined in: generated/mixture/GaussianMixture.ts:463 (opens in a new tab)
score()
Compute the per-sample average log-likelihood of the given data X.
Signature
score(opts: object): Promise<number>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | List of n_features-dimensional data points. Each row corresponds to a single data point. |
opts.y? | any | Not used, present for API consistency by convention. |
Returns
Promise
<number
>
Defined in: generated/mixture/GaussianMixture.ts:498 (opens in a new tab)
score_samples()
Compute the log-likelihood of each sample.
Signature
score_samples(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
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:536 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/mixture/GaussianMixture.ts:23 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/mixture/GaussianMixture.ts:22 (opens in a new tab)
_py
PythonBridge
Defined in: generated/mixture/GaussianMixture.ts:21 (opens in a new tab)
id
string
Defined in: generated/mixture/GaussianMixture.ts:18 (opens in a new tab)
opts
any
Defined in: generated/mixture/GaussianMixture.ts:19 (opens in a new tab)
Accessors
converged_
True when convergence was reached in fit(), false
otherwise.
Signature
converged_(): Promise<boolean>;
Returns
Promise
<boolean
>
Defined in: generated/mixture/GaussianMixture.ts:694 (opens in a new tab)
covariances_
The covariance of each mixture component. The shape depends on covariance\_type
:
Signature
covariances_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/mixture/GaussianMixture.ts:619 (opens in a new tab)
feature_names_in_
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Signature
feature_names_in_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/mixture/GaussianMixture.ts:794 (opens in a new tab)
lower_bound_
Lower bound value on the log-likelihood (of the training data with respect to the model) of the best fit of EM.
Signature
lower_bound_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/mixture/GaussianMixture.ts:744 (opens in a new tab)
means_
The mean of each mixture component.
Signature
means_(): Promise<ArrayLike[]>;
Returns
Promise
<ArrayLike
[]>
Defined in: generated/mixture/GaussianMixture.ts:594 (opens in a new tab)
n_features_in_
Number of features seen during fit.
Signature
n_features_in_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/mixture/GaussianMixture.ts:769 (opens in a new tab)
n_iter_
Number of step used by the best fit of EM to reach the convergence.
Signature
n_iter_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/mixture/GaussianMixture.ts:719 (opens in a new tab)
precisions_
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
:
Signature
precisions_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/mixture/GaussianMixture.ts:644 (opens in a new tab)
precisions_cholesky_
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
:
Signature
precisions_cholesky_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/mixture/GaussianMixture.ts:669 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/mixture/GaussianMixture.ts:120 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/mixture/GaussianMixture.ts:124 (opens in a new tab)
weights_
The weights of each mixture components.
Signature
weights_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/mixture/GaussianMixture.ts:569 (opens in a new tab)