def distances(self, x):
"""Calculates the distance between data x and the centers.
The distance, by default, is calculated according to `metric`, but this
method should be overridden by subclasses if required.
Parameters
----------
x : :obj:`np.ndarray`
(n_samples, n_features)
The original data.
Returns
-------
:obj:`np.ndarray`
(n_samples, n_clusters)
Each entry (i, j) is the distance between sample i and cluster
center j.
"""
return cdist(x, self.centers, metric=self.metric)
评论列表
文章目录