lumicks.pylake.GaussianMixtureModel¶
-
class
GaussianMixtureModel(data, n_states, init_method, n_init, tol, max_iter)¶ A wrapper around scikit-learn’s GMM.
This model accepts a 1D array as training data. The state parameters are sorted according to state mean in order to facilitate comparison of models with different number of states or trained on different datasets. As the current implementation is designed to specifically handle 1D data, model parameters are also returned as 1D arrays (np.squeeze() is applied to the results) so that users do not have to be concerned with the shape of the output results.
Parameters: - data : array-like
Data object used for model training.
- n_states : int
The number of Gaussian components in the model.
- init_method : ‘kmeans’ or ‘random’
The method used to initialize parameters.
- n_init : int
The number of initializations to perform.
- tol : float
The tolerance for training convergence.
- max_iter : int
The maximum number of iterations to perform.
-
__init__(data, n_states, init_method, n_init, tol, max_iter)¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__(data, n_states, init_method, …)Initialize self. from_channel(slc, n_states[, init_method, …])Initialize a model from channel data. hist(trace[, n_bins, plot_kwargs, hist_kwargs])Plot a histogram of the data overlaid with the model PDF. label(trace)Label channel trace data as states. pdf(x)Probability Distribution Function (states as rows). plot(trace[, trace_kwargs, label_kwargs])Plot a time trace with each data point labeled with the state assignment. Attributes
aicAkaike Information Criterion. bicBayesian Information Criterion. exit_flagModel optimization information. meansModel state means. stdModel state standard deviations. variancesModel state variances. weightsModel state weights. -
classmethod
from_channel(slc, n_states, init_method='kmeans', n_init=1, tol=0.001, max_iter=100)¶ Initialize a model from channel data.
Parameters: - slc : Slice
Channel data used for model training.
- n_states : int
The number of Gaussian components in the model.
- init_method : ‘kmeans’ or ‘random’
The method used to initialize parameters.
- n_init : int
The number of initializations to perform.
- tol : float
The tolerance for training convergence.
- max_iter : int
The maximum number of iterations to perform.
-
hist(trace, n_bins=100, plot_kwargs={}, hist_kwargs={})¶ Plot a histogram of the data overlaid with the model PDF.
Parameters: - trace : Slice-like
Data object to histogram.
- n_bins : int
Number of histogram bins.
- plot_kwargs : dict
Plotting keyword arguments passed to the PDF line plot.
- hist_kwargs : dict
Plotting keyword arguments passed to the histogram plot.
-
label(trace)¶ Label channel trace data as states.
-
pdf(x)¶ Probability Distribution Function (states as rows).
-
plot(trace, trace_kwargs={}, label_kwargs={})¶ Plot a time trace with each data point labeled with the state assignment.
Parameters: - trace : Slice-like
Data object to histogram.
- trace_kwargs : dict
Plotting keyword arguments passed to the data line plot.
- label_kwargs : dict
Plotting keyword arguments passed to the state labels plot.
-
aic¶ Akaike Information Criterion.
-
bic¶ Bayesian Information Criterion.
-
exit_flag¶ Model optimization information.
-
means¶ Model state means.
-
std¶ Model state standard deviations.
-
variances¶ Model state variances.
-
weights¶ Model state weights.