def find_neighbours(self, idx, features):
"""
Finds the neighbours of the given point which are at a maximum distance
of self.eps from it.
:param idx: Index of the current point
:param features: Dataset, array-like object of shape
(nb_samples, nb_features)
:returns: List containing the indexes of the neighbours
"""
data = features[np.setdiff1d(np.arange(features.shape[0]), idx)]
distances = self.get_distances(features[idx], data)
same_cluster = [idx]
for i, dist in enumerate(distances.tolist()[0]):
real_index = i if i < idx else i + 1
if dist <= self.eps:
same_cluster.append(real_index)
return same_cluster
评论列表
文章目录