code: def predict(self, data, features=None):
      data = numpy.array(data)
      if features is None:
          features = numpy.ones(self.data.shape[1])
      else:
          features = numpy.array(features)
  
      if data.ndim == 1:
          dist = self.data - data
      elif data.ndim == 2:
          dist = numpy.zeros((data.shape[0],) + self.data.shape)
          for i, d in enumerate(data):
              dist[i, :, :] = self.data - d
      else:
          raise ValueError(
              "Cannot process data with dimensionality > 2"
          )
      dist = features * dist
      dist = dist * dist
      dist = numpy.sum(dist, -1)
      dist = numpy.sqrt(dist)
      nns = numpy.argsort(dist)
  
      if data.ndim == 1:
          classes = dict((cls, 0) for cls in self.classes)
          for n in nns[: self.k]:
              classes[self.labels[n]] += 1
          labels = sorted(classes.items(), key=operator.itemgetter(1))[
              -1
          ][0]
      elif data.ndim == 2:
          labels = list()
          for i, d in enumerate(data):
              classes = dict((cls, 0) for cls in self.classes)
              for n in nns[i, : self.k]:
                  classes[self.labels[n]] += 1
              labels.append(
                  sorted(classes.items(), key=operator.itemgetter(1))[
                      -1
                  ][0]
              )
  
      return labels
  
file_path: deap/examples/ga/knn.py
imports: import numpy
  import csv
  import operator
  import random
label_desc: Use image node_id 3 for calling the KNN obj's underlying member method code with example usage: obj.predict(data, features) and returns: labels