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: Fit the model according to the given training data.
  
  Parameters
  ----------
  X : array of shape (n_samples, n_features)
      Data used to fit the model.
  
  y : array of shape (n_samples)
      class labels of each example in X.
docstr_tok: ["Fit","the","model","according","to","the","given","training","data",".","Parameters","--","--","--","--","--","X",":","array","of","shape","(","n_samples",",","n_features",")","Data","used","to","fit","the","model",".","y",":","array","of","shape","(","n_samples",")","class","labels","of","each","example","in","X","."]
code: def fit(self, X, y):
      """Fit the model according to the given training data.
  
      Parameters
      ----------
      X : array of shape (n_samples, n_features)
          Data used to fit the model.
  
      y : array of shape (n_samples)
          class labels of each example in X.
      """
      X, y = check_X_y(X, y)
  
      self.knns_ = {}
      self.classes_indexes_ = {}
      self.fit_X_ = X
      self.fit_y_ = y
      self.classes_ = np.unique(y)
      self.n_classes_ = self.classes_.size
  
      # Checking inputs
      self._check_n_neighbors(self.n_neighbors)
      self._set_knn_type()
  
      tmp = self._handle_n_neighbors(self.n_neighbors)
      self._mdc, self._mod, self._neighbors_per_class = tmp
      for class_ in self.classes_:
          self.classes_indexes_[class_] = np.argwhere(
              np.array(y) == class_
          ).ravel()
          y_c = y[self.classes_indexes_[class_]]
          X_c = X[self.classes_indexes_[class_], :]
          knn = self.knn_type_(
              n_neighbors=self._neighbors_per_class, **self.kwargs
          )
          self.knns_[class_] = knn.fit(X_c, y_c)
  
      return self
  
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 2 for calling the KNNE obj's underlying member method code with example usage: obj.fit(X, y) and returns: self