kNN#约会网站预测数据

Posted fd-682012

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了kNN#约会网站预测数据相关的知识,希望对你有一定的参考价值。

 1 #约会网站预测数据
 2 def classifyPersion():
 3     resultList = [not at all,in small doses,in large doses]
 4     #input()函数允许用户输入文本行命令并返回用户所输入的命令
 5     percentTats = float(input("percentage of time spent playing video games?"))
 6     ffMiles = float(input("frequent year?"))
 7     iceCream = float(input("liters years?"))
 8     datingDataMat,datingLabels = file2matrix(datingTestSet2.txt)
 9     normMat, ranges, minVals = autoNorm(datingDataMat)
10     inArr = array([ffMiles,percentTats, iceCream])
11     classifierResult = classify0((inArr-minVals)/ranges,normMat,datingLabels,3)
12     print("you like person:",resultList[classifierResult - 1])

 

以上是关于kNN#约会网站预测数据的主要内容,如果未能解决你的问题,请参考以下文章