from numpy import *
import operator
import matplotlib.pyplot as plt
def creatDataset():
group = array([[1.0,1.1],[1.0,1.0],[0,0],[0,0.1]])
lables =['A','A','B','B']
return group,lables
group,lables = creatDataset()
print(group,lables)
datingDataMat = group
fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(datingDataMat[:,1],datingDataMat[:,0])
plt.show()

  

运行结果

K-邻近算法简单例子-LMLPHP

K-邻近算法简单例子-LMLPHP

04-28 10:22