from sklearn import datasets
from sklearn.neighbors import KDTree,KNeighborsClassifier,KernelDensity,KNeighborsTransformerX, y = datasets.load_iris(return_X_y=True)tree = KDTree(X)
dist_to_knn, idx_of_knn = tree.query(X=X[[3]],k=5)
print(dist_to_knn) # 到k个近邻的距离
print(idx_of_knn) # k个近邻的索引