(self, cluster_centers, only_new=True, reset_dist=False)
Update min distances given cluster centers.

        Args:
          cluster_centers: indices of cluster centers
          only_new: only calculate distance for newly selected points and update
            min_distances.
          rest_dist: whether to reset min_distances.
Update min distances given cluster centers.
Update min distances given cluster centers .
def update_distances(self, cluster_centers, only_new=True, reset_dist=False):
        """Update min distances given cluster centers.

        Args:
          cluster_centers: indices of cluster centers
          only_new: only calculate distance for newly selected points and update
            min_distances.
          rest_dist: whether to reset min_distances.
        """
        if reset_dist:
            self.min_distances = None
        if only_new:
            cluster_centers = [d for d in cluster_centers
                               if d not in self.already_selected]
        if cluster_centers:
            # Update min_distances for all examples given new cluster center.
            x = self.features[cluster_centers,:]
            dist = pairwise_distances(self.features, x, metric=self.metric)

            if self.min_distances is None:
                self.min_distances = np.min(dist, axis=1).reshape(-1, 1)
            else:
                if dist.shape[1] != 1:
                    dist = np.min(dist, axis=1).reshape(-1, 1)
                self.min_distances = np.minimum(self.min_distances, dist)
def update_distances ( self , cluster_centers , only_new = True , reset_dist = False ) : if reset_dist : self . min_distances = None if only_new : cluster_centers = [ d for d in cluster_centers if d not in self . already_selected ] if cluster_centers : # Update min_distances for all examples given new cluster center. x = self . features [ cluster_centers , : ] dist = pairwise_distances ( self . features , x , metric = self . metric ) if self . min_distances is None : self . min_distances = np . min ( dist , axis = 1 ) . reshape ( - 1 , 1 ) else : if dist . shape [ 1 ] != 1 : dist = np . min ( dist , axis = 1 ) . reshape ( - 1 , 1 ) self . min_distances = np . minimum ( self . min_distances , dist )