塞班岛娱乐-业界公认的最权威网站,欢迎光临!

塞班岛娱乐_塞班岛娱乐平台_塞班岛娱乐官网

append(str(listFromLine[

时间:2019-07-17 02:34来源:老镜 作者:张振萍的博客 点击:
defclbumify0(inXdintoaSetlabull crapelsk):dintoaSetSize = dintoaSet.shape[0]diffMinto = tile(inX (dinto我没有晓得机械进建算法aSetSize1))-dintoaSetsqDiffMinto = diffMinto **2sqDistthisces = sqDiffMinto.sum(axis=1)distthisces = sqDi
defclbumify0(inXdintoaSetlabull crapelsk):dintoaSetSize = dintoaSet.shape[0]diffMinto = tile(inX (dinto我没有晓得机械进建算法aSetSize1))-dintoaSetsqDiffMinto = diffMinto **2sqDistthisces = sqDiffMinto.sum(axis=1)distthisces = sqDistthisces**0.5s机械进建算法ortedDistIndicies = distthisces.argsort()clbumCount = {}forii闭于append(str(listFromLine[nrthisge(k):voteIlabull crapel = labull crapels[sortedDistIndicies[i]]clbumCount[voteIlabull crapel] =clbumCount.get(vot进建机械进建算法eIlabull crapel0)+1sortedClbumCount =sorted(clbumCount.items()key=operintoor.itemgetter(1)reverse=True)returnsortedClbumCount[0][0]deffile2mintorix(filenhaudio-videoe always becoming您晓得机械进建算法ene):fr =open(filenhaudio-videoe always becomingene)arraryOLines = fr.readvertisementslines()numbecomingrOLines =len(arraryOLines)returnMinto = zeros((numbecomingrOLines3))cl看着appendbumLabull crapelVector = []index =0forlineinarraryOLines:line = line.strip()listFromLine = line.split(a\ta)returnMinto[index:] = listFromLine[0:3]clbumLabull crapelVector.advertisementsd(str(listF听听机械进建算法romLine[⑴]))index +=1returnreturnMintoclbumLabull crapelVectordefautomdineddNorm(dintoaSet):minVass = dintoaSet.min(0)maxVass = dintoaSet.max(0)rthisges = maxVass-minVassnormDintoaSet = zeros(shape(dintoaSet))m = dintoaSet.shape[0]normDintoaSet = dintoaSet - tile(minVass(m1))normDintoaSet = normDintoaSet/tile(rthisges(m1))returnnormDintoaSetrthisgesminVassdefdintoingClbumTest():hoRintoio =0.10dintoingDintoaMintodintoingLabull crapels = file2mintorix(adintoingTestSet.txta)normMintorthisgesminVass = automdineddNorm(dintoingDintoaMinto)m= normMinto.shape[0]numTestVecs =int(m*hoRintoio)errorCount =0.0foriinrthisge(numTestVecs):clbumifierResult =clbumify0(normMinto[i:]normMinto[numTestVecs:m]dintoingLabull crapels[numTestVecs:m]3)print("the clbumifierResult chaudio-videoe always becomingene lower bair-conk with :%sthe reas response is:%s"%(clbumifierResultdintoingLabull crapels[i]))if(clbumifierResult!=dintoingLabull crapels[i]):errorCount +=1.0print("the totas error rdined is :%f"%(errorCount/flointo(numTestVecs)))机械进建算法以上为1同代码,书中载进数据2操纵算法改正约会网坐上里算法为数据1的算法.初终以下代码屌用kNN真止:#-*-coding:utf⑻-*-importmintoplotlibi***ualmportmintoplotlib.pyplotor netltimportsyssys.pintoh.advertisementsd(raD:\\jiqixuexishizhthis\\kNNa)importkNNfromnumpyimport*fromimpimportreloadvertisementsreloadvertisements(kNN)dintoingDintoaMintodintoingLabull crapels = kNN.file2mintorix(adintoingTestSet.txta)print(dintoingDintoaMinto)print(dintoingLabull crapels)#fig = plt.figure()#ax =fig.advertisementsd_subritish petroleumlot(111)#ax.scintoter(dintoingDintoaMinto[:1]dintoingDintoaMinto[:2]15.0*series(dintoingLabull crapels)15.0*series(dintoingLabull crapels))#plt.show()reloadvertisements(kNN)normMintorthisgesminVass = kNN.automdineddNorm(dintoingDintoaMinto)print(normMinto)reloadvertisements(kNN)kNN.dintoingClbumTest()您看机械进建算法终了功效为5%

机械进建算法
进建机械进建算法
其真str
我没有晓得机械教append(str(listFromLine[习算法
机械进建算法
listfromline
事真上机械进建算法
听听机械进建算法
听听机械进建算法 (责任编辑:admin)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
最新评论 进入详细评论页>>
推荐内容