adrianoyuji / knn-with-genetic-algorithm-weights Goto Github PK
View Code? Open in Web Editor NEWI developed an algorithm that generate random values, after, those values are grouped and classificated through k-means algorithm, after that 8 new unclassified individuals are inserted and a weighted KNN starts, creating a random population of weights and proceeds to evaluate them through a fitness function, then it sorts the population and through tournament selection selects two parents and proceeds to breed them to create two children with a good fitness value, the algorithm then breeds 50 times to create a new, better population. It then repeats the process for 5 generations and at the end a optimal weight is selected. After generating this weight the KNN then classificates the unclassified individual.