parameters: (self, X, y=None)
return_statement: return self
docstring: Fit the model to the data X.
  
          Parameters
          ----------
          X : {array-like, sparse matrix} shape (n_samples, n_features)
              Training data.
  
          Returns
          -------
          self : BernoulliRBM
              The fitted model.
docstring_summary: Fit the model to the data X.
docstring_tokens: Fit the model to the data X .
function: def fit(self, X, y=None):
          """Fit the model to the data X.
  
          Parameters
          ----------
          X : {array-like, sparse matrix} shape (n_samples, n_features)
              Training data.
  
          Returns
          -------
          self : BernoulliRBM
              The fitted model.
          """
          X = check_array(X, accept_sparse='csr', dtype=np.float64)
          n_samples = X.shape[0]
          rng = check_random_state(self.random_state)
  
          self.components_ = np.asarray(
              rng.normal(0, 0.01, (self.n_components, X.shape[1])),
              order='F')
          self.intercept_hidden_ = np.zeros(self.n_components, )
          self.intercept_visible_ = np.zeros(X.shape[1], )
          self.h_samples_ = np.zeros((self.batch_size, self.n_components))
  
          n_batches = int(np.ceil(float(n_samples) / self.batch_size))
          batch_slices = list(gen_even_slices(n_batches * self.batch_size,
                                              n_batches, n_samples))
          verbose = self.verbose
          begin = time.time()
          for iteration in xrange(1, self.n_iter + 1):
              for batch_slice in batch_slices:
                  self._fit(X[batch_slice], rng)
  
              if verbose:
                  end = time.time()
                  print("[%s] Iteration %d, pseudo-likelihood = %.2f,"
                        " time = %.2fs"
                        % (type(self).__name__, iteration,
                           self.score_samples(X).mean(), end - begin))
                  begin = end
  
          return self
function_tokens: def fit ( self , X , y = None ) : X = check_array ( X , accept_sparse = 'csr' , dtype = np . float64 ) n_samples = X . shape [ 0 ] rng = check_random_state ( self . random_state ) self . components_ = np . asarray ( rng . normal ( 0 , 0.01 , ( self . n_components , X . shape [ 1 ] ) ) , order = 'F' ) self . intercept_hidden_ = np . zeros ( self . n_components , ) self . intercept_visible_ = np . zeros ( X . shape [ 1 ] , ) self . h_samples_ = np . zeros ( ( self . batch_size , self . n_components ) ) n_batches = int ( np . ceil ( float ( n_samples ) / self . batch_size ) ) batch_slices = list ( gen_even_slices ( n_batches * self . batch_size , n_batches , n_samples ) ) verbose = self . verbose begin = time . time ( ) for iteration in xrange ( 1 , self . n_iter + 1 ) : for batch_slice in batch_slices : self . _fit ( X [ batch_slice ] , rng ) if verbose : end = time . time ( ) print ( "[%s] Iteration %d, pseudo-likelihood = %.2f," " time = %.2fs" % ( type ( self ) . __name__ , iteration , self . score_samples ( X ) . mean ( ) , end - begin ) ) begin = end return self