pmlearn package¶
Subpackages¶
- pmlearn.gaussian_process package
- pmlearn.linear_model package
- pmlearn.mixture package
- pmlearn.naive_bayes package
- pmlearn.neural_network package
- pmlearn.tests package
Submodules¶
pmlearn.base module¶
Base classes for all Bayesian models.
-
class
pmlearn.base.
BayesianClassifierMixin
[source]¶ Bases:
sklearn.base.ClassifierMixin
Mixin for regression models in pmlearn
-
fit
(X, y, inference_type='advi', minibatch_size=None, inference_args=None)[source]¶ Train the Multilayer perceptron model
Parameters: - X (numpy array, shape [n_samples, n_features]) –
- y (numpy array, shape [n_samples, ]) –
- inference_type (string, specifies which inference method to call.) –
- to 'advi'. Currently, only 'advi' and 'nuts' are supported (Defaults) –
- minibatch_size (number of samples to include in each minibatch) –
- ADVI, defaults to None, so minibatch is not run by default (for) –
- inference_args (dict, arguments to be passed to the inference methods.) –
- the PyMC3 docs for permissable values. If no arguments are (Check) –
- default values will be set. (specified,) –
-
-
class
pmlearn.base.
BayesianDensityMixin
[source]¶ Bases:
sklearn.base.DensityMixin
Mixin for regression models in pmlearn
-
fit
(X, num_components, inference_type='advi', minibatch_size=None, inference_args=None)[source]¶ Train the Gaussian Mixture Model model
Parameters: - X (numpy array, shape [n_samples, n_features]) –
- n_truncate (numpy array, shape [n_samples, ]) –
- inference_type (string, specifies which inference method to call.) –
- to 'advi'. Currently, only 'advi' and 'nuts' are supported (Defaults) –
- minibatch_size (number of samples to include in each minibatch for) –
- ADVI, –
- to None, so minibatch is not run by default (defaults) –
- inference_args (dict, arguments to be passed to the inference methods.) –
- the PyMC3 docs for permissable values. If no arguments are (Check) –
- specified, –
- values will be set. (default) –
-
predict
(X)[source]¶ Predicts labels of new data with a trained model
Parameters: - X (numpy array, shape [n_samples, n_features]) –
- cats (numpy array, shape [n_samples, ]) –
-
predict_proba
(X, return_std=False)[source]¶ Predicts probabilities of new data with a trained GaussianMixture Model
Parameters: - X (numpy array, shape [n_samples, n_features]) –
- cats (numpy array, shape [n_samples, ]) –
- return_std (Boolean flag of whether to return standard deviations with) –
- probabilities. Defaults to False. (mean) –
-
-
class
pmlearn.base.
BayesianModel
[source]¶ Bases:
sklearn.base.BaseEstimator
Base class for all Bayesian models in pymc-learn
Notes
All Bayesian models should specify all the parameters that can be set at the class level in their
__init__
as explicit keyword arguments (no*args
or **kwargs``).-
load
(file_prefix, load_custom_params=False)[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, custom_params=None)[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.base.
BayesianRegressorMixin
[source]¶ Bases:
sklearn.base.RegressorMixin
Mixin for regression models in pmlearn
-
fit
(X, y, inference_type='advi', minibatch_size=None, inference_args=None)[source]¶ Train the Linear Regression model
Parameters: - X (numpy array, shape [n_samples, n_features]) –
- y (numpy array, shape [n_samples, ]) –
- inference_type (string, specifies which inference method to call.) – Defaults to ‘advi’. Currently, only ‘advi’ and ‘nuts’ are supported
- minibatch_size (number of samples to include in each minibatch for) – ADVI, defaults to None, so minibatch is not run by default
- inference_args (dict, arguments to be passed to the inference methods.) – Check the PyMC3 docs for permissable values. If no arguments are specified, default values will be set.
-
pmlearn.exceptions module¶
The pmlearn.exceptions
module includes all custom warnings and error
classes used across pymc-learn.
-
exception
pmlearn.exceptions.
NotFittedError
[source]¶ Bases:
ValueError
,AttributeError
Exception class to raise if estimator is used before fitting. This class inherits from both ValueError and AttributeError to help with exception handling and backward compatibility. .. rubric:: Examples
>>> from pmlearn.gaussian_process import GaussianProcessRegressor >>> from pmlearn.exceptions import NotFittedError >>> try: ... GaussianProcessRegressor().predict([[1, 2], [2, 3], [3, 4]]) ... except NotFittedError as e: ... print(repr(e)) ... NotFittedError('This GaussianProcessRegressor instance is not fitted yet'.)
Module contents¶
Probabilistic machine learning module for Python¶
pmlearn is a Python module for practical probabilistic machine learning built on top of scikit-learn and PymC3.
It aims to provide simple and efficient solutions to learning problems that are accessible to everybody and reusable in various contexts: machine-learning as a versatile tool for science and engineering. See http://pymc-learn.org for complete documentation.