parameters: (self, X, y)
docstring: Compute out-of-bag scores.
docstring_summary: Compute out-of-bag scores.
docstring_tokens: Compute out - of - bag scores .
function: def _set_oob_score(self, X, y):
          """
          Compute out-of-bag scores."""
          X = check_array(X, dtype=DTYPE, accept_sparse='csr')
  
          n_samples = y.shape[0]
  
          predictions = np.zeros((n_samples, self.n_outputs_))
          n_predictions = np.zeros((n_samples, self.n_outputs_))
  
          n_samples_bootstrap = _get_n_samples_bootstrap(
              n_samples, self.max_samples
          )
  
          for estimator in self.estimators_:
              unsampled_indices = _generate_unsampled_indices(
                  estimator.random_state, n_samples, n_samples_bootstrap)
              p_estimator = estimator.predict(
                  X[unsampled_indices, :], check_input=False)
  
              if self.n_outputs_ == 1:
                  p_estimator = p_estimator[:, np.newaxis]
  
              predictions[unsampled_indices, :] += p_estimator
              n_predictions[unsampled_indices, :] += 1
  
          if (n_predictions == 0).any():
              warn("Some inputs do not have OOB scores. "
                   "This probably means too few trees were used "
                   "to compute any reliable oob estimates.")
              n_predictions[n_predictions == 0] = 1
  
          predictions /= n_predictions
          self.oob_prediction_ = predictions
  
          if self.n_outputs_ == 1:
              self.oob_prediction_ = \
                  self.oob_prediction_.reshape((n_samples, ))
  
          self.oob_score_ = 0.0
  
          for k in range(self.n_outputs_):
              self.oob_score_ += r2_score(y[:, k],
                                          predictions[:, k])
  
          self.oob_score_ /= self.n_outputs_
function_tokens: def _set_oob_score ( self , X , y ) : X = check_array ( X , dtype = DTYPE , accept_sparse = 'csr' ) n_samples = y . shape [ 0 ] predictions = np . zeros ( ( n_samples , self . n_outputs_ ) ) n_predictions = np . zeros ( ( n_samples , self . n_outputs_ ) ) n_samples_bootstrap = _get_n_samples_bootstrap ( n_samples , self . max_samples ) for estimator in self . estimators_ : unsampled_indices = _generate_unsampled_indices ( estimator . random_state , n_samples , n_samples_bootstrap ) p_estimator = estimator . predict ( X [ unsampled_indices , : ] , check_input = False ) if self . n_outputs_ == 1 : p_estimator = p_estimator [ : , np . newaxis ] predictions [ unsampled_indices , : ] += p_estimator n_predictions [ unsampled_indices , : ] += 1 if ( n_predictions == 0 ) . any ( ) : warn ( "Some inputs do not have OOB scores. " "This probably means too few trees were used " "to compute any reliable oob estimates." ) n_predictions [ n_predictions == 0 ] = 1 predictions /= n_predictions self . oob_prediction_ = predictions if self . n_outputs_ == 1 : self . oob_prediction_ = self . oob_prediction_ . reshape ( ( n_samples , ) ) self . oob_score_ = 0.0 for k in range ( self . n_outputs_ ) : self . oob_score_ += r2_score ( y [ : , k ] , predictions [ : , k ] ) self . oob_score_ /= self . n_outputs_