Compute Covariance#
covariance
#
| FUNCTION | DESCRIPTION |
|---|---|
covariance_diag |
Compute diagonal covariance matrices for each component. |
covariance_spherical |
Compute spherical covariance matrices for each component. |
covariance_full |
Compute full covariance matrices for each component. |
covariance_tied |
Compute tied covariance matrix shared across all components. |
log_prob_gaussian_diag |
Compute log probabilities for Gaussian mixture with diagonal covariances. |
log_prob_gaussian_spherical |
Compute log probabilities for Gaussian mixture with spherical covariances. |
log_prob_gaussian_full |
Compute log probabilities for Gaussian mixture with full covariances. |
log_prob_gaussian_tied |
Compute log probabilities for Gaussian mixture with tied covariance. |
Functions#
covariance_diag(X: torch.Tensor, resp: torch.Tensor, weights: torch.Tensor, means: torch.Tensor, eps: float = torch.finfo(torch.float32).eps) -> torch.Tensor
#
Compute diagonal covariance matrices for each component.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Data tensor of shape (n_samples, n_features).
TYPE:
|
resp
|
Responsibilities of shape (n_samples, n_components).
TYPE:
|
weights
|
Sample weights of shape (n_samples,).
TYPE:
|
means
|
Component means of shape (n_components, n_features).
TYPE:
|
eps
|
Regularization term for numerical stability.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Diagonal covariances of shape (n_components, n_features). |
Source code in spectre/compute/covariance.py
covariance_spherical(X: torch.Tensor, resp: torch.Tensor, weights: torch.Tensor, means: torch.Tensor, eps: float = torch.finfo(torch.float32).eps) -> torch.Tensor
#
Compute spherical covariance matrices for each component.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Data tensor of shape (n_samples, n_features).
TYPE:
|
resp
|
Responsibilities of shape (n_samples, n_components).
TYPE:
|
weights
|
Sample weights of shape (n_samples,).
TYPE:
|
means
|
Component means of shape (n_components, n_features).
TYPE:
|
eps
|
Regularization term for numerical stability.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Spherical covariances of shape (n_components, 1). |
Source code in spectre/compute/covariance.py
covariance_full(X: torch.Tensor, resp: torch.Tensor, weights: torch.Tensor, means: torch.Tensor, eps: float = torch.finfo(torch.float32).eps) -> torch.Tensor
#
Compute full covariance matrices for each component.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Data tensor of shape (n_samples, n_features).
TYPE:
|
resp
|
Responsibilities of shape (n_samples, n_components).
TYPE:
|
weights
|
Sample weights of shape (n_samples,).
TYPE:
|
means
|
Component means of shape (n_components, n_features).
TYPE:
|
eps
|
Regularization term for numerical stability.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Full covariances of shape (n_components, n_features, n_features). |
Source code in spectre/compute/covariance.py
covariance_tied(X: torch.Tensor, resp: torch.Tensor, weights: torch.Tensor, means: torch.Tensor, eps: float = torch.finfo(torch.float32).eps) -> torch.Tensor
#
Compute tied covariance matrix shared across all components.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Data tensor of shape (n_samples, n_features).
TYPE:
|
resp
|
Responsibilities of shape (n_samples, n_components).
TYPE:
|
weights
|
Sample weights of shape (n_samples,).
TYPE:
|
means
|
Component means of shape (n_components, n_features).
TYPE:
|
eps
|
Regularization term for numerical stability.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Tied covariance of shape (n_features, n_features). |
Source code in spectre/compute/covariance.py
log_prob_gaussian_diag(X: torch.Tensor, means: torch.Tensor, covariances: torch.Tensor, weights: torch.Tensor, eps: float = torch.finfo(torch.float32).eps) -> torch.Tensor
#
Compute log probabilities for Gaussian mixture with diagonal covariances.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Data tensor of shape (n_samples, n_features).
TYPE:
|
means
|
Component means of shape (n_components, n_features).
TYPE:
|
covariances
|
Diagonal covariances of shape (n_components, n_features).
TYPE:
|
weights
|
Mixing weights of shape (n_components,).
TYPE:
|
eps
|
Regularization term for numerical stability.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Log probabilities of shape (n_samples, n_components). |
Source code in spectre/compute/covariance.py
log_prob_gaussian_spherical(X: torch.Tensor, means: torch.Tensor, covariances: torch.Tensor, weights: torch.Tensor, eps: float = torch.finfo(torch.float32).eps) -> torch.Tensor
#
Compute log probabilities for Gaussian mixture with spherical covariances.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Data tensor of shape (n_samples, n_features).
TYPE:
|
means
|
Component means of shape (n_components, n_features).
TYPE:
|
covariances
|
Spherical covariances of shape (n_components, 1).
TYPE:
|
weights
|
Mixing weights of shape (n_components,).
TYPE:
|
eps
|
Regularization term for numerical stability.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Log probabilities of shape (n_samples, n_components). |
Source code in spectre/compute/covariance.py
log_prob_gaussian_full(X: torch.Tensor, means: torch.Tensor, covariances: torch.Tensor, weights: torch.Tensor, eps: float = torch.finfo(torch.float32).eps) -> torch.Tensor
#
Compute log probabilities for Gaussian mixture with full covariances.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Data tensor of shape (n_samples, n_features).
TYPE:
|
means
|
Component means of shape (n_components, n_features).
TYPE:
|
covariances
|
Full covariances of shape (n_components, n_features, n_features).
TYPE:
|
weights
|
Mixing weights of shape (n_components,).
TYPE:
|
eps
|
Regularization term for numerical stability.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Log probabilities of shape (n_samples, n_components). |
Source code in spectre/compute/covariance.py
log_prob_gaussian_tied(X: torch.Tensor, means: torch.Tensor, covariances: torch.Tensor, weights: torch.Tensor, eps: float = 1e-07) -> torch.Tensor
#
Compute log probabilities for Gaussian mixture with tied covariance.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Data tensor of shape (n_samples, n_features).
TYPE:
|
means
|
Component means of shape (n_components, n_features).
TYPE:
|
covariances
|
Tied covariance of shape (n_features, n_features).
TYPE:
|
weights
|
Mixing weights of shape (n_components,).
TYPE:
|
eps
|
Regularization term for numerical stability.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Log probabilities of shape (n_samples, n_components). |