一、数据集Iris data ----虹膜
150个实例
萼片长度,萼片宽度,花瓣长度,花瓣宽度
(sepal length,sepal width,patel length,patel width)
类别
Iris setosa,iris versicolor, iris virginica
二、sklearn
from sklearn import neighbors
from sklearn import datasets
knn=neighbors.KNeighborsClassifier()#调用分类器
iris=datasets.load_iris()#数据集
# print(iris)
#建立模型(建模)
knn.fit(iris.data,iris.target)
#预测新分类
newrow=[[0.1,0.2,0.3,0.4]]
predictedLabel=knn.predict(newrow)
print(predictedLabel)