本文整理匯總了Python中KNN.img2vector方法的典型用法代碼示例。如果您正苦於以下問題:Python KNN.img2vector方法的具體用法?Python KNN.img2vector怎麽用?Python KNN.img2vector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類KNN
的用法示例。
在下文中一共展示了KNN.img2vector方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testimg2vector
# 需要導入模塊: import KNN [as 別名]
# 或者: from KNN import img2vector [as 別名]
def testimg2vector():
returnVector = zeros((1,1024))
returnVector = KNN.img2vector('./testDigits/0_13.txt')
print(returnVector[0,0:31]) # first row
print(returnVector[0,32:63])# 2nd and 3rd rows
示例2: print
# 需要導入模塊: import KNN [as 別名]
# 或者: from KNN import img2vector [as 別名]
group,labels=KNN.createDateSet()
print group
print labels
print (KNN.classify0([0,0],group,labels,3))
'''
'''
datingDataMat,datingLabels=KNN.file2matrix('C:\Users\YAN\Desktop\data\datingTestSet2\datingTestSet2.txt')
from numpy import *
import matplotlib
import matplotlib.pyplot as plt
fig=plt.figure()
ax=fig.add_subplot(111)
'''
'''
#scatter(x, y, s=20, c=u'b', marker=u'o', cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, hold=None, **kwargs)
ax.scatter(datingDataMat[:,1],datingDataMat[:,2])
'''
'''
ax.scatter(datingDataMat[:,1],datingDataMat[:,2],15.0*array(datingLabels),15.0*array(datingLabels))
plt.show()
'''
'''
normMat,ranges,minVals=KNN.autoNorm(datingDataMat)
KNN.datingClassTest("C:\Users\YAN\Desktop\data\datingTestSet2\datingTestSet2.txt")
'''
testVector=KNN.img2vector("trainingDigits/0_13.txt")
KNN.handwritingClassTest()