E-step for EM algorithm for document clustering

I have a code for the E-step in the EM algorithm for Document Clustering in the version of hard-EM algorithm. I'm trying to implement the E-step for soft-EM algorithm. Here is my code for Hard-EM:

E.step - function(gamma, model, counts){
  N - dim(counts)[2] # number of documents
  K - dim(model$mu)[1]
  for (n in 1:N){
    for (k in 1:K){
       gamma[n,k] - log(model$rho[k,1]) +  sum(counts[,n] * log(model$mu[k,])) 
    }
    logZ = logSum(gamma[n,])
    gamma[n,] = gamma[n,] - logZ
  } 
  gamma - exp(gamma)
  return (gamma)
}

I want to implement a E-step for SOFT - EM algorithm. Any suggestions will be helpful.

Thanks in advance.

Topic expectation-maximization r machine-learning

Category Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.