def _step_E(self, points):
"""
In this step the algorithm evaluates the responsibilities of each points in each cluster
Parameters
----------
points : an array (n_points,dim)
Returns
-------
log_resp: an array (n_points,n_components)
an array containing the logarithm of the responsibilities.
log_prob_norm : an array (n_points,)
logarithm of the probability of each sample in points
"""
n_points,dim = points.shape
log_gaussian = _log_normal_matrix(points,self.means,self.cov,'full',self.n_jobs)
log_gaussian -= 0.5 * dim * np.log(self.nu)
digamma_sum = np.sum(psi(.5 * (self.nu - np.arange(0, dim)[:,np.newaxis])),0)
log_lambda = digamma_sum + dim * np.log(2)
log_prob = self.log_weights + log_gaussian + 0.5 * (log_lambda - dim / self.beta)
log_prob_norm = logsumexp(log_prob, axis=1)
log_resp = log_prob - log_prob_norm[:,np.newaxis]
return log_prob_norm,log_resp
评论列表
文章目录