def _labels_inertia_precompute_dense(X, x_squared_norms, centers, distances):
 n_samples = X.shape[0]
 (labels, mindist) = pairwise_distances_argmin_min(X=X, Y=centers, metric='euclidean', metric_kwargs={'squared': True})
 labels = labels.astype(np.int32)
 if (n_samples == distances.shape[0]):
  distances[:] = mindist
 inertia = mindist.sum()
 return (labels, inertia)

def _labels_inertia_precompute_dense ( X , x_squared_norms , centers , distances ) : n_samples = X . shape [ 0 ] ( labels , mindist ) = pairwise_distances_argmin_min ( X = X , Y = centers , metric = 'euclidean' , metric_kwargs = { 'squared' : True } ) labels = labels . astype ( np . int32 ) if ( n_samples == distances . shape [ 0 ] ) : distances [ : ] = mindist inertia = mindist . sum ( ) return ( labels , inertia )
compute labels and inertia using a full distance matrix .