1 KNN 算法 knn,k-NearestNeighbor,即寻找与点最近的k个点. 2 KNN numpy实现 效果: k=1 k=2 3 numpy 广播,聚合操作. 这里求距离函数,求某点和集合中所有点的距离 def getDistance(points): return np.sum((points[:,np.newaxis,:]-points[np.newaxis,:,:])**2,axis=-1) points[:,np.newaxis,:]-points[np.newaxis,:…