dbscan.py 文件源码

python
阅读 41 收藏 0 点赞 0 评论 0

项目:pylearning 作者: amstuta 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号