class_docstr: Wrapper for using nmslib as sklearn's KNeighborsTransformer
class_docstr_tok: ["Wrapper","for","using","nmslib","as","sklearn","'s","KNeighborsTransformer"]
code: def fit(self, X):
      self.n_samples_fit_ = X.shape[0]
  
      # see more metric in the manual
      # https://github.com/nmslib/nmslib/tree/master/manual
      space = {
          "euclidean": "l2",
          "cosine": "cosinesimil",
          "l1": "l1",
          "l2": "l2",
      }[self.metric]
  
      self.nmslib_ = nmslib.init(method=self.method, space=space)
      self.nmslib_.addDataPointBatch(X.copy())
      self.nmslib_.createIndex()
      return self
  
file_path: scikit-learn/examples/neighbors/approximate_nearest_neighbors.py
imports: import sys
  import joblib
  import numpy
  from scipy.sparse import csr_matrix
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.datasets import fetch_openml
  from sklearn.utils import shuffle
  import time
  from sklearn.manifold import TSNE
  from sklearn.neighbors import KNeighborsTransformer
  from sklearn.pipeline import make_pipeline
  import matplotlib.pyplot
  from matplotlib.ticker import NullFormatter
label_desc: Use image node_id 2 for calling the NMSlibTransformer obj's underlying member method code with example usage: obj.fit(X) and returns: self