Description: The following codes recieves the coordinates of two dots with n dimensions. It calculates the manhanttan distance of theses two dots The codes:
def manhanttan( ponto1, ponto2 ):
totalp1 = 0
totalp2 = 0
for x in range( 0, len( ponto1 ) ):
totalp1 += ponto1[x]
totalp2 += ponto2[x]
return abs( totalp1 - totalp2 )
and
def manhanttan( ponto1, ponto2 ):
total = 0
for x in range( 0, len( ponto1 ) ):
total += abs( ponto1[x] - ponto2[x] )
return total
are giving different results and i don't know why. Can somebody help me?
PS: All values in the lists are positives
PS2: With the first one my classifications gets
K1: Expected Class: 6, Found Class: 0
K2: Expected Class: 6, Found Class: 0
K3: Expected Class: 6, Found Class: 0
K4: Expected Class: 6, Found Class: 0
K5: Expected Class: 6, Found Class: 0
and with the other i get
K1: Expected Class: 6, Found Class: 6
K2: Expected Class: 6, Found Class: 6
K3: Expected Class: 6, Found Class: 6
K4: Expected Class: 6, Found Class: 6
K5: Expected Class: 6, Found Class: 6