简单地说, k-近邻算法采用测量不同特征值之间的距离方法进行分类。
k-近邻算法
适用数据范围: 数值型和标称型。
k-近邻算法的一般流程
from numpy import * import operator
def createDataSet(): group = array([[1.0,1.1],[1.0,1.0],[0,0],[0,0.1]]) labels = ['A','A','B','B'] return group, labels
group, labels = createDataSet()
group
array([[1. , 1.1], [1. , 1. ], [0. , 0. ], [0. , 0.1]])
labels
['A', 'A', 'B', 'B']
a = tile([3,3],(4,1)) a
array([[3, 3], [3, 3], [3, 3], [3, 3]])
其伪代码如下:
对末知类别属性的数据集中的每个点依次执行以下操作:
def classify0(inX, dataSet, labels, k): dataSetSize = dataSet.shape[0] diffMat = tile(inX,(dataSetSize,1)) - dataSet sqDiffMat = diffMat**2 sqDistances = sqDiffMat.sum(axis=1) distances = sqDistances**0.5 sortedDistIndicies = distances.argsort() classCount = {} for i in range(k): voteIlabel = labels[sortedDistIndicies[i]] classCount[voteIlabel] = classCount.get(voteIlabel,0) + 1 sortedClassCount = sorted(classCount.items(),key = operator.itemgetter(1), reverse=True) return sortedClassCount[0][0]
classify0([0,0],group,labels,3)
'B'
数据集如下图:
示例: 使用k-近邻算法的手写识别系统
图像转换为向量
def img2vector(filename): returnVect = zeros((1,1024)) fr = open(filename) for i in range(32): lineStr = fr.readline() for j in range(32): returnVect[0,32*i+j] = int(lineStr[j]) return returnVect
testVector = img2vector('digits/testDigits/0_13.txt') testVector[0,0:31]
array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
from os import listdir
def handwritingClassTest(): hwLables = [] trainingFileList = listdir('digits/trainingDigits') m = len(trainingFileList) trainingMat = zeros((m,1024)) for i in range(m): fileNameStr = trainingFileList[i] fileStr = fileNameStr.split('.')[0] classNumStr = int(fileStr.split('_')[0]) hwLables.append(classNumStr) trainingMat[i,:] = img2vector('digits/trainingDigits/%s' % fileNameStr) testFileList = listdir('digits/testDigits') errorCount = 0.0 mTest = len(testFileList) for i in range(mTest): fileNameStr = testFileList[i] fileStr = fileNameStr.split('.')[0] classNumStr = int(fileStr.split('_')[0]) vectorUnderTest = img2vector('digits/testDigits/%s' % fileNameStr) classifierResult = classify0(vectorUnderTest, trainingMat,hwLables,3) print("the classifier came back width: %d, the real answer is: %d" % (classifierResult,classNumStr)) if(classifierResult != classNumStr): errorCount += 1.0 print("\nthe total number of errors is :%d" % errorCount) print("\nthe total error rate is:%f" % (errorCount/float(mTest)))
handwritingClassTest()
the classifier came back width: 8, the real answer is: 8 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 3, the real answer is: 8 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 6, the real answer is: 8 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 1, the real answer is: 8 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 3, the real answer is: 5 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 1, the real answer is: 8 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 7, the real answer is: 1 the classifier came back width: 7, the real answer is: 9 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 9 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 6, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 9, the real answer is: 3 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 7, the real answer is: 7 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 9, the real answer is: 9 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 6, the real answer is: 6 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 3, the real answer is: 3 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 1, the real answer is: 1 the classifier came back width: 2, the real answer is: 2 the classifier came back width: 8, the real answer is: 8 the classifier came back width: 4, the real answer is: 4 the classifier came back width: 0, the real answer is: 0 the classifier came back width: 5, the real answer is: 5 the classifier came back width: 8, the real answer is: 8 the total number of errors is :10 the total error rate is:0.010571