original_docstring: 
          Initializes locality-sensitive hashing with FALCONN to find nearest neighbors in training data.
          
docstring: Initializes locality-sensitive hashing with FALCONN to find nearest neighbors in training data.
docstring_tokens: Initializes locality - sensitive hashing with FALCONN to find nearest neighbors in training data .
code: def __falconn_fit(self):
          """
          Initializes locality-sensitive hashing with FALCONN to find nearest neighbors in training data.
          """
  
          import falconn
  
          dimension = self.features.shape[1]
          nb_tables = self.kwargs['nb_tables']
          number_bits = self.kwargs['number_bits']
  
          # LSH parameters
          params_cp = falconn.LSHConstructionParameters()
          params_cp.dimension = dimension
          params_cp.lsh_family = falconn.LSHFamily.CrossPolytope
          params_cp.distance_function = falconn.DistanceFunction.EuclideanSquared
          params_cp.l = nb_tables
          params_cp.num_rotations = 2  # for dense set it to 1; for sparse data set it to 2
          params_cp.seed = 5721840
          # we want to use all the available threads to set up
          params_cp.num_setup_threads = 0
          params_cp.storage_hash_table = falconn.StorageHashTable.BitPackedFlatHashTable
  
          # we build number_bits-bit hashes so that each table has
          # 2^number_bits bins; a rule of thumb is to have the number
          # of bins be the same order of magnitude as the number of data points
          falconn.compute_number_of_hash_functions(number_bits, params_cp)
          self._falconn_table = falconn.LSHIndex(params_cp)
          self._falconn_query_object = None
          self._FALCONN_NB_TABLES = nb_tables
  
          # Center the dataset and the queries: this improves the performance of LSH quite a bit.
          self.center    = np.mean(self.features, axis=0)
          self.features -= self.center
  
          # add features to falconn table
          self._falconn_table.setup(self.features)
code_tokens: def __falconn_fit ( self ) : import falconn dimension = self . features . shape [ 1 ] nb_tables = self . kwargs [ 'nb_tables' ] number_bits = self . kwargs [ 'number_bits' ] params_cp = falconn . LSHConstructionParameters ( ) params_cp . dimension = dimension params_cp . lsh_family = falconn . LSHFamily . CrossPolytope params_cp . distance_function = falconn . DistanceFunction . EuclideanSquared params_cp . l = nb_tables params_cp . num_rotations = 2 params_cp . seed = 5721840 params_cp . num_setup_threads = 0 params_cp . storage_hash_table = falconn . StorageHashTable . BitPackedFlatHashTable falconn . compute_number_of_hash_functions ( number_bits , params_cp ) self . _falconn_table = falconn . LSHIndex ( params_cp ) self . _falconn_query_object = None self . _FALCONN_NB_TABLES = nb_tables self . center = np . mean ( self . features , axis = 0 ) self . features -= self . center self . _falconn_table . setup ( self . features )
short_docstring: Initializes locality-sensitive hashing with FALCONN to find nearest neighbors in training data.
short_docstring_tokens: Initializes locality - sensitive hashing with FALCONN to find nearest neighbors in training data .
comment: """
          Initializes locality-sensitive hashing with FALCONN to find nearest neighbors in training data.
          """$SEP$# LSH parameters$SEP$# for dense set it to 1; for sparse data set it to 2$SEP$# we want to use all the available threads to set up$SEP$# we build number_bits-bit hashes so that each table has$SEP$# 2^number_bits bins; a rule of thumb is to have the number$SEP$# of bins be the same order of magnitude as the number of data points$SEP$# Center the dataset and the queries: this improves the performance of LSH quite a bit.$SEP$# add features to falconn table