文件名称:Classify.py
文件大小:1KB
文件格式:PY
更新时间:2023-04-05 03:32:19
分类 python 机器学习 源代码
from sklearn.neighbors import KNeighborsClassifier X = [[0], [1], [2], [3], [4], [5], [6], [7], [8]]#data y = [0, 0, 0, 1, 1, 1, 2, 2, 2]#target neigh = KNeighborsClassifier(n_neighbors=3) neigh.fit(X, y)