You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have encountered some difficulties in understanding the initialization of new categories based on the selected data set (Kmeans++).
More specifically, the code in DiagGaussObsModel.py
` def calcSmoothedMu(self, X, W=None):
''' Compute smoothed estimate of mean of statistic xxT.
Args
----
X : 2D array, size N x D
Returns
-------
Mu_1 : 2D array, size D
Expected value of Var[ X[n,d] ]
Mu_2 : 1D array, size D
Expected value of Mean[ X[n] ]
'''
if X is None:
Mu1 = self.Prior.beta / self.Prior.nu
Mu2 = self.Prior.m
return Mu1, Mu2
if X.ndim == 1:
X = X[np.newaxis,:]
N, D = X.shape
# Compute suff stats
if W is None:
sum_wxx = np.sum(np.square(X), axis=0)
sum_wx = np.sum(X, axis=0)
sum_w = X.shape[0]
else:
W = as1D(W)
sum_wxx = np.dot(W, np.square(X))
sum_wx = np.dot(W, X)
sum_w = np.sum(W)
post_kappa = self.Prior.kappa + sum_w
post_m = (self.Prior.m * self.Prior.kappa + sum_wx) / post_kappa
Mu_2 = post_m
prior_kmm = self.Prior.kappa * (self.Prior.m * self.Prior.m)
post_kmm = post_kappa * (post_m * post_m)
post_beta = sum_wxx + self.Prior.beta + prior_kmm - post_kmm
Mu_1 = post_beta / (self.Prior.nu + sum_w)
assert Mu_1.ndim == 1
assert Mu_1.shape == (D,)
assert Mu_2.shape == (D,)
return Mu_1, Mu_2`
I know that it is calculating the center of the initial category, but I can't understand the rules of this calculation. Can you give me some advice?
` def calcSmoothedMu(self, X, W=None):
Compute smoothed estimate of mean of statistic xxT.
Args
----
X : 2D array, size N x D
Returns
-------
Mu : 2D array, size D x D
'''
Prior_nu = self.Prior.nu - self.D - 1
# Prior_nu = self.Prior.nu
if X is None:
Mu = self.Prior.B / (Prior_nu)
return Mu
if X.ndim == 1:
X = X[np.newaxis,:]
N, D = X.shape
# Compute suff stats
if W is None:
sum_wxxT = np.dot(X.T, X)
sum_w = X.shape[0]
else:
W = as1D(W)
wX = np.sqrt(W)[:,np.newaxis] * X
sum_wxxT = np.dot(wX.T, wX)
sum_w = np.sum(W)
Mu = (self.Prior.B + sum_wxxT) / (Prior_nu + sum_w)
assert Mu.ndim == 2
assert Mu.shape == (D, D,)
return Mu`
The text was updated successfully, but these errors were encountered:
wangjiusi
changed the title
Generate new components
Generate new components in data
Dec 18, 2018
Hi, I am bothering you again.
I have encountered some difficulties in understanding the initialization of new categories based on the selected data set (Kmeans++).
More specifically, the code in DiagGaussObsModel.py
` def calcSmoothedMu(self, X, W=None):
''' Compute smoothed estimate of mean of statistic xxT.
I know that it is calculating the center of the initial category, but I can't understand the rules of this calculation. Can you give me some advice?
Similarly, the code in ZeroMeanGaussObsModel.py
` def calcSmoothedMu(self, X, W=None):
Compute smoothed estimate of mean of statistic xxT.
The text was updated successfully, but these errors were encountered: