Home > other >  Problems in a python dictionary
Problems in a python dictionary

Time:09-26

Appear this kind of error, the code can change ah

CodePudding user response:

Code can't read, stick it up

CodePudding user response:

reference 1/f, ice all over the sky the wind response:
can't read code, code stick it up

That, to send you, lazy, and cut a piece of,,,

CodePudding user response:

The code in figure
The from numpy import *
The import operator


Def data () :
Group=array ([[1.0, 1.1], [1.0, 1.0], [0, 0], [0, 0.1]])
Labels=[' a ', 'a', 'b', 'b']
The return group, labels


Def classify0 (inX, dataSet, labels, k) :
DataSize=dataSet. Shape [0]
DiffMat=tile (inX, (dataSize, 1)) - the 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 iteritems (), key=operator. Itemgetter (1), reverse=True)
Return sortedClasscount [0] [0]

CodePudding user response:

refer to the second floor JackpotG response:
Quote: refer to 1st floor ice all over the sky the wind response:
code can't see, code to stick it up

That, to send you, lazy, and cut a piece of,,,

Code downstairs, bosses help a look
  • Related