Last active
January 16, 2017 05:30
-
-
Save thmain/c2cf2831d16071ad312994d078fde999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def CalculateNeighborsClass(neighbors,k): | |
count = {}; | |
for i in range(k): | |
if(neighbors[i][1] not in count): | |
#The class at the ith index is not in the count dict. | |
#Initialize it to 1. | |
count[neighbors[i][1]] = 1; | |
else: | |
#Found another item of class c[i]. | |
#Increment its counter. | |
count[neighbors[i][1]] += 1; | |
return count; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment