其他分享
首页 > 其他分享> > kNN#约会网站预测数据

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,datingLabels,normMat,网站,约会,float,iceCream,doses,input
来源: https://www.cnblogs.com/fd-682012/p/11579301.html