import numpy as np
import pandas as pd
from sklearn import neighbors
dic1 = {'id':[0,1,2,3,4,5,6,7,8],'yvwen':[72,66,89,81,86,91,86,89,94],'shuxue':[92,81,80,79,68,79,74,78,61], 'ClassifyResult':[3,3,2,2,1,1,1,1,1]}
df = pd.DataFrame(dic1)
print(df)
train_x = df.iloc[0:7,1:3]
print(train_x)
train_y = df.iloc[0:7,3]
print(train_y)
model = neighbors.KNeighborsClassifier()
model.fit(train_x,train_y)
print('###')
print(model)
test_x = df.iloc[7:9,1:3]
print(test_x)
test_p = model.predict(test_x)
print(test_p)
test_y = df.iloc[7:9,3].values
print(test_y)
print(model.score(test_x,test_y))