I am trying to implement the code for GMM manually following the guide at this link
for another dataset with text messages.
I am getting a LinAlgError because of singular matrix when calculating probability density function. Cannot find out where I am going wrong.
mu = initial_means
pi=initial_pi
sigma=initial_cov
N = X.shape[0]
gamma = np.zeros((N,C))
const_c = np.zeros(C)
for c in range(C):
# Posterior Distribution using Bayes Rule
zz= mvn.pdf(X,mu[c,:],sigma[c,:])
print(zz)
gamma[:,c] = pi[c] * zz
# normalize across columns to make a valid probability
gamma_norm = np.sum(gamma, axis=1)[:,np.newaxis]
gamma /= gamma_norm