pmlearn.mixture package¶
Subpackages¶
Submodules¶
pmlearn.mixture.dirichlet_process module¶
Dirichlet Process Mixture Model.
-
class
pmlearn.mixture.dirichlet_process.
DirichletProcessMixture
[source]¶ Bases:
pmlearn.base.BayesianModel
,pmlearn.base.BayesianDensityMixin
Custom Dirichlet Process Mixture Model built using PyMC3.
-
create_model
()[source]¶ Creates and returns the PyMC3 model.
Note: The size of the shared variables must match the size of the training data. Otherwise, setting the shared variables later will raise an error. See http://docs.pymc.io/advanced_theano.html
The DensityDist class is used as the likelihood term. The second argument, logp_gmix(mus, pi, np.eye(D)), is a python function which recieves observations (denoted by ‘value’) and returns the tensor representation of the log-likelihood.
Returns: Return type: the PyMC3 model
-
load
(file_prefix)[source]¶ Loads a saved version of the trace, and custom param files with the given file_prefix.
Parameters: - file_prefix (str, path and prefix used to identify where to load the) –
- trace for this model. (saved) – Ex: given file_prefix = “path/to/file/” This will attempt to load “path/to/file/trace.pickle”
- load_custom_params (Boolean flag to indicate whether custom parameters) –
- be loaded. Defaults to False. (should) –
Returns: custom_params
Return type: Dictionary of custom parameters
-
predict_proba
(X, return_std=False)[source]¶ Predicts probabilities of new data with a trained Dirichlet Process Mixture Model
Parameters: - X (numpy array, shape [n_samples, n_features]) –
- cats (numpy array, shape [n_samples, ]) –
- return_std (Boolean flag) – Boolean flag of whether to return standard deviations with mean probabilities. Defaults to False.
-
save
(file_prefix)[source]¶ Saves the trace and custom params to files with the given file_prefix.
Parameters: - file_prefix (str, path and prefix used to identify where to save the) –
- for this model. (trace) – Ex: given file_prefix = “path/to/file/” This will attempt to save to “path/to/file/trace.pickle”
- custom_params (Dictionary of custom parameters to save.) – Defaults to None
-
pmlearn.mixture.gaussian_mixture module¶
Gaussian Mixture Model.
-
class
pmlearn.mixture.gaussian_mixture.
GaussianMixture
[source]¶ Bases:
pmlearn.base.BayesianModel
,pmlearn.base.BayesianDensityMixin
Custom Gaussian Mixture Model built using PyMC3.
-
create_model
()[source]¶ Creates and returns the PyMC3 model.
Note: The size of the shared variables must match the size of the training data. Otherwise, setting the shared variables later will raise an error. See http://docs.pymc.io/advanced_theano.html
Returns: Return type: the PyMC3 model
-
load
(file_prefix)[source]¶ Loads a saved version of the trace, and custom param files with the given file_prefix.
Parameters: - file_prefix (str, path and prefix used to identify where to load the) –
- trace for this model. (saved) – Ex: given file_prefix = “path/to/file/” This will attempt to load “path/to/file/trace.pickle”
- load_custom_params (Boolean flag to indicate whether custom parameters) –
- be loaded. Defaults to False. (should) –
Returns: custom_params
Return type: Dictionary of custom parameters
-
save
(file_prefix)[source]¶ Saves the trace and custom params to files with the given file_prefix.
Parameters: - file_prefix (str, path and prefix used to identify where to save the) –
- for this model. (trace) – Ex: given file_prefix = “path/to/file/” This will attempt to save to “path/to/file/trace.pickle”
- custom_params (Dictionary of custom parameters to save.) – Defaults to None
-
pmlearn.mixture.util module¶
Module contents¶
The pmlearn.mixture
module implements mixture models.
-
class
pmlearn.mixture.
GaussianMixture
[source]¶ Bases:
pmlearn.base.BayesianModel
,pmlearn.base.BayesianDensityMixin
Custom Gaussian Mixture Model built using PyMC3.
-
create_model
()[source]¶ Creates and returns the PyMC3 model.
Note: The size of the shared variables must match the size of the training data. Otherwise, setting the shared variables later will raise an error. See http://docs.pymc.io/advanced_theano.html
Returns: Return type: the PyMC3 model
-
load
(file_prefix)[source]¶ Loads a saved version of the trace, and custom param files with the given file_prefix.
Parameters: - file_prefix (str, path and prefix used to identify where to load the) –
- trace for this model. (saved) – Ex: given file_prefix = “path/to/file/” This will attempt to load “path/to/file/trace.pickle”
- load_custom_params (Boolean flag to indicate whether custom parameters) –
- be loaded. Defaults to False. (should) –
Returns: custom_params
Return type: Dictionary of custom parameters
-
save
(file_prefix)[source]¶ Saves the trace and custom params to files with the given file_prefix.
Parameters: - file_prefix (str, path and prefix used to identify where to save the) –
- for this model. (trace) – Ex: given file_prefix = “path/to/file/” This will attempt to save to “path/to/file/trace.pickle”
- custom_params (Dictionary of custom parameters to save.) – Defaults to None
-
-
class
pmlearn.mixture.
DirichletProcessMixture
[source]¶ Bases:
pmlearn.base.BayesianModel
,pmlearn.base.BayesianDensityMixin
Custom Dirichlet Process Mixture Model built using PyMC3.
-
create_model
()[source]¶ Creates and returns the PyMC3 model.
Note: The size of the shared variables must match the size of the training data. Otherwise, setting the shared variables later will raise an error. See http://docs.pymc.io/advanced_theano.html
The DensityDist class is used as the likelihood term. The second argument, logp_gmix(mus, pi, np.eye(D)), is a python function which recieves observations (denoted by ‘value’) and returns the tensor representation of the log-likelihood.
Returns: Return type: the PyMC3 model
-
load
(file_prefix)[source]¶ Loads a saved version of the trace, and custom param files with the given file_prefix.
Parameters: - file_prefix (str, path and prefix used to identify where to load the) –
- trace for this model. (saved) – Ex: given file_prefix = “path/to/file/” This will attempt to load “path/to/file/trace.pickle”
- load_custom_params (Boolean flag to indicate whether custom parameters) –
- be loaded. Defaults to False. (should) –
Returns: custom_params
Return type: Dictionary of custom parameters
-
predict_proba
(X, return_std=False)[source]¶ Predicts probabilities of new data with a trained Dirichlet Process Mixture Model
Parameters: - X (numpy array, shape [n_samples, n_features]) –
- cats (numpy array, shape [n_samples, ]) –
- return_std (Boolean flag) – Boolean flag of whether to return standard deviations with mean probabilities. Defaults to False.
-
save
(file_prefix)[source]¶ Saves the trace and custom params to files with the given file_prefix.
Parameters: - file_prefix (str, path and prefix used to identify where to save the) –
- for this model. (trace) – Ex: given file_prefix = “path/to/file/” This will attempt to save to “path/to/file/trace.pickle”
- custom_params (Dictionary of custom parameters to save.) – Defaults to None
-