code: def _expectation(self, X):
          
  
          # Calculate probabilities of X belonging to the different clusters
          weighted_likelihoods = self._get_likelihoods(X) * self.priors
          sum_likelihoods = np.expand_dims(np.sum(weighted_likelihoods, axis=1), axis=1)
          # Determine responsibility as P(X|y)*P(y)/P(X)
          self.responsibility = weighted_likelihoods / sum_likelihoods
          # Assign samples to cluster that has largest probability
          self.sample_assignments = self.responsibility.argmax(axis=1)
          # Save value for convergence check
          self.responsibilities.append(np.max(self.responsibility, axis=1))
docs: Calculate the responsibility