code: def getNeighbors(trainingSet, testInstance, k, considerDimensions=None):
    
    if considerDimensions is None:
      considerDimensions = len(testInstance) - 1
  
    neighborList = []
    for x in range(len(trainingSet)):
      dist = euclideanDistance(testInstance, trainingSet[x], considerDimensions)
      neighborList.append((trainingSet[x], dist))
    neighborList.sort(key=operator.itemgetter(1))
  
    neighbors = []
    distances = []
    for x in range(k):
      neighbors.append(neighborList[x][0])
      distances.append(neighborList[x][1])
  
    return neighbors
docs: collect the k most similar instances in the trainingSet for a given test
    instance
    :param trainingSet: A list of data instances
    :param testInstance: a single data instance
    :param k: number of neighbors
    :param considerDimensions: a list of dimensions to consider
    :return: neighbors: a list of neighbor instance