class_docstr: "
  Implementation of the K-Nearest Neighbors-Equality technique.
  
  This implementation fits a different KNN method for each class, and search
  on each class for the nearest examples.
  
  Parameters
  ----------
  
  n_neighbors : int, (default = 7)
      Number of neighbors to use by default for :meth:`kneighbors` queries.
  
  algorithm : str = ['knn', 'faiss]', (default = 'knn')
      Whether to use scikit-learn or faiss for nearest neighbors estimation.
  
  References
  ----------
  Sierra, Basilio, Elena Lazkano, Itziar Irigoien, Ekaitz Jauregi,
  and Iñigo Mendialdua. "K nearest neighbor equality: giving equal chance
  to all existing classes."
  Information Sciences 181, no. 23 (2011): 5158-5168.
  
  Mendialdua, Iñigo, José María Martínez-Otzeta, I. Rodriguez-Rodriguez,
  T. Ruiz-Vazquez, and Basilio Sierra. "Dynamic selection of the best base
  classifier in one versus one." Knowledge-Based Systems 85 (2015): 298-306.
  
  Cruz, Rafael MO, Dayvid VR Oliveira, George DC Cavalcanti,
  and Robert Sabourin. "FIRE-DES++: Enhanced online pruning of base
  classifiers for dynamic ensemble selection."
  Pattern Recognition 85 (2019): 149-160.
class_docstr_tok: ["``","Implementation","of","the","K-Nearest","Neighbors-Equality","technique",".","This","implementation","fits","a","different","KNN","method","for","each","class",",","and","search","on","each","class","for","the","nearest","examples",".","Parameters","--","--","--","--","--","n_neighbors",":","int",",","(","default","=","7",")","Number","of","neighbors","to","use","by","default","for",":","meth",":","`","kneighbors","`","queries",".","algorithm",":","str","=","[","'knn","'",",","'faiss","]","'",",","(","default","=","'knn","'",")","Whether","to","use","scikit-learn","or","faiss","for","nearest","neighbors","estimation",".","References","--","--","--","--","--","Sierra",",","Basilio",",","Elena","Lazkano",",","Itziar","Irigoien",",","Ekaitz","Jauregi",",","and","I\u00f1igo","Mendialdua",".","``","K","nearest","neighbor","equality",":","giving","equal","chance","to","all","existing","classes",".","''","Information","Sciences","181",",","no",".","23","(","2011",")",":","5158-5168",".","Mendialdua",",","I\u00f1igo",",","Jos\u00e9","Mar\u00eda","Mart\u00ednez-Otzeta",",","I.","Rodriguez-Rodriguez",",","T.","Ruiz-Vazquez",",","and","Basilio","Sierra",".","``","Dynamic","selection","of","the","best","base","classifier","in","one","versus","one",".","''","Knowledge-Based","Systems","85","(","2015",")",":","298-306",".","Cruz",",","Rafael","MO",",","Dayvid","VR","Oliveira",",","George","DC","Cavalcanti",",","and","Robert","Sabourin",".","``","FIRE-DES++",":","Enhanced","online","pruning","of","base","classifiers","for","dynamic","ensemble","selection",".","''","Pattern","Recognition","85","(","2019",")",":","149-160","."]
docstr: Finds the K-neighbors of a point.
  Returns indices of and distances to the neighbors of each point.
  
  Parameters
  ----------
  X : array-like, shape (n_query, n_features),                 or (n_query, n_indexed) if metric == 'precomputed'
      The query point or points.
      If not provided, neighbors of each indexed point are returned.
      In this case, the query point is not considered its own neighbor.
  
  n_neighbors : int
      Number of neighbors to get (default is the value
      passed to the constructor).
  
  return_distance : boolean, optional. Defaults to True.
      If False, distances will not be returned
  
  Returns
  -------
  dist : array
      Array representing the lengths to points, only present if
      return_distance=True
  
  ind : array
      Indices of the nearest points in the population matrix.
docstr_tok: ["Finds","the","K-neighbors","of","a","point",".","Returns","indices","of","and","distances","to","the","neighbors","of","each","point",".","Parameters","--","--","--","--","--","X",":","array-like",",","shape","(","n_query",",","n_features",")",",","or","(","n_query",",","n_indexed",")","if","metric","==","'precomputed'","The","query","point","or","points",".","If","not","provided",",","neighbors","of","each","indexed","point","are","returned",".","In","this","case",",","the","query","point","is","not","considered","its","own","neighbor",".","n_neighbors",":","int","Number","of","neighbors","to","get","(","default","is","the","value","passed","to","the","constructor",")",".","return_distance",":","boolean",",","optional",".","Defaults","to","True",".","If","False",",","distances","will","not","be","returned","Returns","--","--","--","-","dist",":","array","Array","representing","the","lengths","to","points",",","only","present","if","return_distance=True","ind",":","array","Indices","of","the","nearest","points","in","the","population","matrix","."]
code: def kneighbors(self, X=None, n_neighbors=None, return_distance=True):
      """Finds the K-neighbors of a point.
          Returns indices of and distances to the neighbors of each point.
  
          Parameters
          ----------
          X : array-like, shape (n_query, n_features), \
                  or (n_query, n_indexed) if metric == 'precomputed'
              The query point or points.
              If not provided, neighbors of each indexed point are returned.
              In this case, the query point is not considered its own neighbor.
  
          n_neighbors : int
              Number of neighbors to get (default is the value
              passed to the constructor).
  
          return_distance : boolean, optional. Defaults to True.
              If False, distances will not be returned
  
          Returns
          -------
          dist : array
              Array representing the lengths to points, only present if
              return_distance=True
  
          ind : array
              Indices of the nearest points in the population matrix.
          """
      if n_neighbors is None:
          neighbors_per_class = self._neighbors_per_class
          mdc = self._mdc
          mod = self._mod
      else:
          mdc, mod, neighbors_per_class = self._handle_n_neighbors(
              n_neighbors
          )
  
      if X is None:
          X = self.fit_X_
  
      dists = []
      inds = []
      mod_dists = []
      mod_inds = []
      for class_, knn in self.knns_.items():
          dist_c, ind_c = knn.kneighbors(X, neighbors_per_class)
          real_ind_c = self.classes_indexes_[class_].take(ind_c)
          dists.append(dist_c[:, 0:mdc])
          inds.append(real_ind_c[:, 0:mdc])
          if mod > 0:
              mod_dists.append(dist_c[:, -1].reshape(-1, 1))
              mod_inds.append(real_ind_c[:, -1].reshape(-1, 1))
  
      dists, inds = self._organize_neighbors(dists, inds)
  
      if mod > 0:
          mod_dists, mod_inds = self._organize_neighbors(
              mod_dists, mod_inds
          )
          dists = np.hstack((dists, mod_dists[:, 0:mod]))
          inds = np.hstack((inds, mod_inds[:, 0:mod]))
  
      if return_distance:
          return dists, inds
      else:
          return inds
  
file_path: DESlib/deslib/util/knne.py
imports: import warnings
  import numpy
  from sklearn.base import BaseEstimator
  from sklearn.neighbors import KNeighborsClassifier
  from sklearn.utils import check_X_y
  from sklearn.utils import check_array
  from deslib.util import faiss_knn_wrapper
  from deslib.util.prob_functions import softmax
label_desc: Use image node_id 3 for calling the KNNE obj's underlying member method code with example usage: obj.kneighbors(X, n_neighbors, return_distance) and returns: dists,  inds, inds