def _labels_inertia(X, x_squared_norms, centers, precompute_distances=True, distances=None):
 n_samples = X.shape[0]
 labels = (- np.ones(n_samples, np.int32))
 if (distances is None):
  distances = np.zeros(shape=(0,), dtype=X.dtype)
 if sp.issparse(X):
  inertia = _k_means._assign_labels_csr(X, x_squared_norms, centers, labels, distances=distances)
 else:
  if precompute_distances:
   return _labels_inertia_precompute_dense(X, x_squared_norms, centers, distances)
  inertia = _k_means._assign_labels_array(X, x_squared_norms, centers, labels, distances=distances)
 return (labels, inertia)

def _labels_inertia ( X , x_squared_norms , centers , precompute_distances = True , distances = None ) : n_samples = X . shape [ 0 ] labels = ( - np . ones ( n_samples , np . int32 ) ) if ( distances is None ) : distances = np . zeros ( shape = ( 0 , ) , dtype = X . dtype ) if sp . issparse ( X ) : inertia = _k_means . _assign_labels_csr ( X , x_squared_norms , centers , labels , distances = distances ) else : if precompute_distances : return _labels_inertia_precompute_dense ( X , x_squared_norms , centers , distances ) inertia = _k_means . _assign_labels_array ( X , x_squared_norms , centers , labels , distances = distances ) return ( labels , inertia )
e step of the k-means em algorithm .