def classifyPerson():
resultList = ['not at all','in small doses','in large doses']
percentTats = float(raw_input("percentage of time spent playing video games?"))
ffMiles = float(raw_input("frequent flier miles earned per year?"))
iceCream = float(raw_input("liters of ice cream consumed per year?"))
datingDataMat,datingLabels = file2matrix('datingTestSet2.txt')
normMat,ranges,minVals = autoNorm(datingDataMat)
inArr = array([ffMiles,percentTats,iceCream])
classifierResult = classify0((inArr-minVals)/ranges,normMat,datingLabels,3)
print("You will probably like this person: ",resultList[classifierResult - 1])
函数raw_input(),允许用户输入文本行命令,并返回用户所输入的命令,在命令行中输入的……
EOL while scanning string literal
这个异常造成的原因是字符串,引号没有成对出现
日常粗心,然后就各种踩坑
NameError: name 'raw_input' is not defined
2.7 raw_input 3.6 直接input
>>> import kNN
>>> from imp import reload
>>> reload(kNN)
<module 'kNN' from 'E:\\Python\\kNN.py'>
>>> kNN.classifyPerson()
percentage of time spent playing video games?10
frequent flier miles earned per year?10000
liters of ice cream consumed per year?0.5
You will probably like this person: in small doses
>>>