机器学习实战笔记(1)
程序员文章站
2022-06-12 15:42:39
...
Python 2.7
安装Numpy函数库
安装Matplotlib函数库
kNN1.py
Run Module F5
>>> from numpy import *
>>> group,labels=createDataSet()
>>> classify0([0,0],group,labels,3)
>>> datingDataMat,datingLabels=file2matrix('datingTestSet2.txt')
>>> import matplotlib
>>> import matplotlib.pyplot as plt
>>> fig=plt.figure()
>>> ax = fig.add_subplot(111)
>>> ax.scatter(datingDataMat[:,1],datingDataMat[:,2],15.0*array(datingLabels),15.0*array(datingLabels))
>>> plt.show()