TODO update this page
The diagonal Gaussian observation model generates each data vector \(x_n\) of length D from a multivariate Gaussian with mean \(\mu_k \in \mathbb{R}^D\) and a diagonal covariance matrix:
The global random variables are the cluster-specific means and precisions (inverse variances).
For each cluster k, we have the following global random variables:
Each dataset observation at index n has its own cluster assignment:
The generative model and approximate posterior for \(z_n\) is determined by an allocation model. For all computations needed by our current observation model, we’ll assume either a point estimate or an approximate posterior for \(z_n\) is known.
Each dimension d has a mean \(\mu_{kd}\) and variance \(\lambda_{kd}\) which have a joint univariate Normal-Wishart prior with scalar hyperparameters \(\bar{\nu}, \bar{\beta}_d\) for the Wishart prior and then \(\bar{m}_d, \bar{\kappa}\) for the Normal prior:
These are represented by the following numpy array attributes of the Prior
parameter bag:
nu
floatdegrees of freedom
beta
1D array, size Dscale parameters that set mean of lambda
m
1D array, size Dmean of the parameter mu
kappa
floatscalar precision of mu
Several keyword arguments can be used to determine the values of the prior hyperparameters when calling bnpy.run
--nu
floatSets value of \(\bar{\nu}\). Defaults to D + 2.
--kappa
floatSets value of \(\bar{\kappa}\). Defaults to ???.
--ECovMat
strDetermines the expected value of data covariance under the prior. Possible values include ‘eye’ and ‘diagcovdata’. TODO
--sF
floatThese two options set the value of \(\bar{\beta}\). TODO.
TODO set m??
We assume the following factorized approximate posterior family for variational optimization:
The specific forms of the global and local factors are given below.
For each observation vector at index n, we assume an independent approximate posterior over the assigned cluster indicator \(z_n \in \{1, 2, \ldots K \}\).
Thus, for this observation model the only local variational parameter is the assignment responsibility array \(\hat{r} = \{ \{ \hat{r}_{nk} \}_{k=1}^K \}_{n=1}^N\).
Inside the LP dict, this is represented by the resp numpy array:
resp
2D array, size N x KParameters of approximate posterior q(z) over cluster assignments. resp[n,k] = probability observation n is assigned to component k.
Remember, all computations required by our observation model assume that the resp
array is given. The actual values of resp
are updated by an allocation model.
The goal of variational optimization is to find the best approximate posterior distribution for the mean and precision parameters of each cluster k:
This approximate posterior is represented by the Post attribute of the DiagGaussObsModel. This is a ParamBag with the following attributes:
K
intnumber of active clusters
nu
1D array, size KDefines \(\hat{\nu}_k\) for each cluster
beta
2D array, size K x DDefines \(\hat{\beta}_{kd}\) for each cluster and dimension
m
2D array, size K x DDefines \(\hat{m}_{kd}\) for each cluster and dimension
kappa
2D array, size KDefines \(\hat{\kappa}_{k}\) for each cluster
Variational optimization will find the approximate posterior parameters that maximize the following objective function, given a fixed observed dataset \(x = \{x_1, \ldots x_N \}\) and fixed prior hyparparameters \(\bar{\nu}, \bar{\beta}, \bar{m}, \bar{\kappa}\).
This objective function is computed by calling the Python function calc_evidence
.
The sufficient statistics of this observation model are functions of the local parameters \(\hat{r}\) and the observed data \(x\).
These fields are stored within the sufficient statistics parameter bag SS
as the following fields:
SS.N
1D array, size KSS.N[k] = \(N_k\)
SS.x
2D array, size K x DSS.x[k,d] = \(S^{x}_{kd}(x, \hat{r})\)
SS.xx
2D array, size K x DSS.xx[k,d] = \(S^{x^2}_{kd}(x, \hat{r})\)
The cumulant function of the univariate Normal-Wishart is evaluated for each dimension d separately. The function takes 4 scalar input arguments and produces a scalar output.
As with all observation models, the local step computes the expected log conditional probability of assigning each observation to each cluster:
where the elementary expectations required are:
In our implementation, this is done via the function calc_local_params
, which computes the following arrays and places them inside the local parameter dict LP
.
E_log_soft_ev
2D array, N x Klog probability of assigning each observation n to each cluster k
The global step update produces an updated approximate posterior over the global random variables. Concretely, this means updated values for each field of the Post
ParamBag attribute of the DiagGaussObsModel.
Our implementation performs this update when calling the function update_global_params
.
Initialization creates valid values of the parameters which define the approximate posterior over the global random variables. Concretely, this means it creates a valid setting of the Post
attribute of the DiagGaussObsModel object.
TODO