class_docstr: Classification by k-nearest neighbors.
  
  Classification by k-nearest neighbors (k-NN). For each point of the test
  set, the pairwise distance to each element of the training set is
  estimated. The class is affected according to the majority class of the
  k-nearest neighbors.
  
  Parameters
  ----------
  n_neighbors : int, default=5
      Number of neighbors.
  metric : string | dict, default='riemann'
      The type of metric used for distance estimation.
      see `distance` for the list of supported metric.
  n_jobs : int, default=1
      The number of jobs to use for the computation. This works by computing
      each of the distance to the training set in parallel.
      If -1 all CPUs are used. If 1 is given, no parallel computing code is
      used at all, which is useful for debugging. For n_jobs below -1,
      (n_cpus + 1 + n_jobs) are used. Thus for n_jobs = -2, all CPUs but one
      are used.
  
  Attributes
  ----------
  classes_ : ndarray, shape (n_classes,)
      Labels for each class.
  covmeans_ : ndarray, shape (n_matrices, n_channels, n_channels)
      Matrices of training set.
  classmeans_ : ndarray, shape (n_matrices,)
      Labels of training set.
  
  See Also
  --------
  Kmeans
  MDM
class_docstr_tok: ["Classification","by","k-nearest","neighbors",".","Classification","by","k-nearest","neighbors","(","k-NN",")",".","For","each","point","of","the","test","set",",","the","pairwise","distance","to","each","element","of","the","training","set","is","estimated",".","The","class","is","affected","according","to","the","majority","class","of","the","k-nearest","neighbors",".","Parameters","--","--","--","--","--","n_neighbors",":","int",",","default=5","Number","of","neighbors",".","metric",":","string","|","dict",",","default='riemann'","The","type","of","metric","used","for","distance","estimation",".","see","`","distance","`","for","the","list","of","supported","metric",".","n_jobs",":","int",",","default=1","The","number","of","jobs","to","use","for","the","computation",".","This","works","by","computing","each","of","the","distance","to","the","training","set","in","parallel",".","If","-1","all","CPUs","are","used",".","If","1","is","given",",","no","parallel","computing","code","is","used","at","all",",","which","is","useful","for","debugging",".","For","n_jobs","below","-1",",","(","n_cpus","+","1","+","n_jobs",")","are","used",".","Thus","for","n_jobs","=","-2",",","all","CPUs","but","one","are","used",".","Attributes","--","--","--","--","--","classes_",":","ndarray",",","shape","(","n_classes",",",")","Labels","for","each","class",".","covmeans_",":","ndarray",",","shape","(","n_matrices",",","n_channels",",","n_channels",")","Matrices","of","training","set",".","classmeans_",":","ndarray",",","shape","(","n_matrices",",",")","Labels","of","training","set",".","See","Also","--","--","--","--","Kmeans","MDM"]
docstr: Get the predictions.
  
  Parameters
  ----------
  X : ndarray, shape (n_matrices, n_channels, n_channels)
      Set of SPD matrices.
  
  Returns
  -------
  pred : ndarray of int, shape (n_matrices,)
      Predictions for each matrix according to the closest centroid.
docstr_tok: ["Get","the","predictions",".","Parameters","--","--","--","--","--","X",":","ndarray",",","shape","(","n_matrices",",","n_channels",",","n_channels",")","Set","of","SPD","matrices",".","Returns","--","--","--","-","pred",":","ndarray","of","int",",","shape","(","n_matrices",",",")","Predictions","for","each","matrix","according","to","the","closest","centroid","."]
code: def predict(self, X=None, covtest=None):
      """Get the predictions.
  
      Parameters
      ----------
      X : ndarray, shape (n_matrices, n_channels, n_channels)
          Set of SPD matrices.
  
      Returns
      -------
      pred : ndarray of int, shape (n_matrices,)
          Predictions for each matrix according to the closest centroid.
      """
      if covtest is not None:
          warnings.warn(
              "Input covtest has been renamed into X and will be "
              "removed in 0.8.0.",
              category=DeprecationWarning,
          )
          assert X is None
          X = covtest
  
      dist = self._predict_distances(X)
      neighbors_classes = self.classmeans_[np.argsort(dist)]
      pred = _mode_2d(
          neighbors_classes[:, 0 : self.n_neighbors], axis=1
      )
      return pred
  
imports: import functools
  import numpy
  from sklearn.base import BaseEstimator, ClassifierMixin, TransformerMixin
  from sklearn.svm import SVC
  from sklearn.utils.extmath import softmax
  from sklearn.linear_model import LogisticRegression
  from sklearn.pipeline import make_pipeline
  from joblib import Parallel, delayed
  import warnings
  from .utils.kernel import kernel
  from .utils.mean import mean_covariance, mean_power
  from .utils.distance import distance
  from .tangentspace import FGDA, TangentSpace
label_desc: Use image node_id 3 for calling the KNearestNeighbor obj's underlying member method code with example usage: obj.predict(X, covtest) and returns: pred