askcarl package
Submodules
askcarl.gaussian module
Multivariate Gaussians with support for upper limits and missing data.
- askcarl.gaussian.pdfcdf(x, mask, mean, cov)[source]
Compute the mixed PDF and CDF for a multivariate Gaussian distribution.
- Parameters:
x (array) – The point (vector) at which to evaluate the probability.
mask (array) – A boolean mask of the same shape as x, indicating whether the entry is a value (True) or a upper bound (False).
mean (array) – mean vector of the multivariate normal distribution.
cov (array) – covariance matrix of the multivariate normal distribution.
- Returns:
pdf – Probability density
- Return type:
float
- class askcarl.gaussian.Gaussian(mean, cov)[source]
Bases:
object
Multivariate Gaussians with support for upper limits and missing data.
- Parameters:
mean (array) – mean vector of the multivariate normal distribution.
cov (array) – covariance matrix of the multivariate normal distribution.
- get_conditional_rv(mask)[source]
Build conditional distribution.
- Parameters:
mask (array) – A boolean mask, indicating whether the entry is a value (True) or a upper bound (False).
- Returns:
cov_cross (array) – Covariance matrix part of upper bound and value dimensions.
cov_exact (array) – Covariance matrix part of value dimensions.
inv_cov_exact (array) – Inverse covariance matrix part of value dimensions.
rv (scipy.stats.multivariate_normal) – Multivariate Normal Distribution of the upper bound dimensions, conditioned with mask.
- conditional_pdf(x, mask=Ellipsis)[source]
Compute conditional PDF.
- Parameters:
x (array) – The points (vector) at which to evaluate the probability.
mask (array) – A boolean mask of the same shape as x.shape[1], indicating whether the entry is a value (True) or a upper bound (False).
- Returns:
pdf – Probability density. One value for each x.
- Return type:
array
- conditional_logpdf(x, mask=Ellipsis)[source]
Compute conditional log-PDF.
- Parameters:
x (array) – The points (vector) at which to evaluate the probability.
mask (array) – A boolean mask of the same shape as x.shape[1], indicating whether the entry is a value (True) or a upper bound (False).
- Returns:
logpdf – logarithm of the probability density. One value for each x.
- Return type:
array
- pdf(x, mask)[source]
Compute conditional PDF.
- Parameters:
x (array) – The points (vector) at which to evaluate the probability.
mask (array) – A boolean mask of the same shape as x, indicating whether the entry is a value (True) or a upper bound (False).
- Returns:
pdf – probability density. One value for each x.
- Return type:
array
- logpdf(x, mask)[source]
Compute conditional log-PDF.
- Parameters:
x (array) – The points (vector) at which to evaluate the probability.
mask (array) – A boolean mask of the same shape as x, indicating whether the entry is a value (True) or a upper bound (False).
- Returns:
logpdf – logarithm of the probability density. One value for each x.
- Return type:
array
askcarl.lightgmm module
A extremely fast-to-train GMM.
- class askcarl.lightgmm.LightGMM(n_components, refine_weights=False, init_kwargs={'init': 'random', 'max_iter': 1, 'n_init': 1}, warm_start=False, covariance_type='full')[source]
Bases:
object
Wrapper which transforms KMeans results into a GMM.
Initialise.
- Parameters:
n_components (int) – number of Gaussian components.
refine_weights (bool) – whether to include a E step at the end.
init_kwargs (dict) – arguments passed to KMeans
warm_start (bool) – not supported, has to be False
covariance_type (str) – only “full” is supported
- fit(X, sample_weight=None)[source]
Fit.
- Parameters:
X (array) – data, of shape (N, D)
sample_weight (array) – weights of observations. shape (N,)
- to_sklearn()[source]
Convert to a scikit-learn GaussianMixture object.
- Returns:
gmm – scikit-learn GaussianMixture
- Return type:
object
- score_samples(X)[source]
Compute score of samples.
- Parameters:
X (array) – data, of shape (N, D)
- Returns:
logprob – log-probabilities, one entry for each entry in X, of shape (N)
- Return type:
array
askcarl.mixture module
Mixture of Gaussians.
- class askcarl.mixture.GaussianMixture(weights, means, covs)[source]
Bases:
object
Mixture of Gaussians.
- Parameters:
weights (list) – weight for each Gaussian component
means (list) – mean vector for each Gaussian component.
covs (list) – covariance matrix for each Gaussian component.
- weights
weight for each Gaussian component
- Type:
list
- components
list of Gaussian components.
- Type:
list
- static from_pypmc(mix)[source]
Initialize from a pypmc Gaussian mixture model (GMM).
- Parameters:
mix (pypmc.density.mixture.GaussianMixture) – Gaussian mixture.
- Returns:
mix – Generalized Gaussian mixture.
- Return type:
GaussianMixture
- static from_sklearn(skgmm)[source]
Initialize from a scikit-learn Gaussian mixture model (GMM).
- Parameters:
mix (sklearn.mixture.GaussianMixture) – Gaussian mixture.
- Returns:
mix – Generalized Gaussian mixture.
- Return type:
GaussianMixture
- pdf(x, mask)[source]
Compute probability density at x.
- Parameters:
x (array) – The points (vector) at which to evaluate the probability.
mask (array) – A boolean mask of the same shape as x, indicating whether the entry is a value (True) or a upper bound (False).
- Returns:
pdf – probability density. One value for each x.
- Return type:
array
- logpdf(x, mask)[source]
Compute logarithm of probability density.
- Parameters:
x (array) – The points (vector) at which to evaluate the probability.
mask (array) – A boolean mask of the same shape as x, indicating whether the entry is a value (True) or a upper bound (False).
- Returns:
logpdf – logarithm of the probability density. One value for each x.
- Return type:
array
Module contents
Multivariate Gaussians with support for upper limits and missing data.