def euclideanDistance(instance1, instance2, considerDimensions):
  """
  Calculate Euclidean Distance between two samples
  Example use:
  data1 = [2, 2, 2, 'class_a']
  data2 = [4, 4, 4, 'class_b']
  distance = euclideanDistance(data1, data2, 3)

  :param instance1: list of attributes
  :param instance2: list of attributes
  :param considerDimensions: a list of dimensions to consider
  :return: float euclidean distance between data1 & 2
  """
  distance = 0
  for x in considerDimensions:
    distance += pow((instance1[x] - instance2[x]), 2)
  return math.sqrt(distance)
def euclideanDistance ( instance1 , instance2 , considerDimensions ) : distance = 0 for x in considerDimensions : distance += pow ( ( instance1 [ x ] - instance2 [ x ] ) , 2 ) return math . sqrt ( distance )
Calculate Euclidean Distance between two samples
  Example use:
  data1 = [2, 2, 2, 'class_a']
  data2 = [4, 4, 4, 'class_b']
  distance = euclideanDistance(data1, data2, 3)

  :param instance1: list of attributes
  :param instance2: list of attributes
  :param considerDimensions: a list of dimensions to consider
  :return: float euclidean distance between data1 & 2