original_docstring: 
      A wrapper for the Scikit-Learn Bootstrap method.
      
docstring: A wrapper for the Scikit-Learn Bootstrap method.
docstring_tokens: A wrapper for the Scikit - Learn Bootstrap method .
code: def SKLearnBootstrap(X_train, y_train, reg, N_bs, test_percent=0.4,
                       X_test=None, y_test=None, shuffle=False):
      """
      A wrapper for the Scikit-Learn Bootstrap method.
      """
  
      # Checks if we have provided test data or not
      if ((isinstance(X_test, type(None))) and
              (isinstance(y_test, type(None)))):
  
          # Splits X data and design matrix data
          X_train, X_test, y_train, y_test = \
              sk_modsel.train_test_split(X_train, y_train,
                                         test_size=test_percent,
                                         shuffle=shuffle)
  
      # Storage containers for results
      y_pred_array = np.empty((y_test.shape[0], N_bs))
      r2_array = np.empty(N_bs)
      mse_array = np.empty(N_bs)
  
      beta_coefs = []
  
      # for i_bs, val_ in enumerate(bs):
      for i_bs in tqdm(range(N_bs), desc="SKLearnBootstrap"):
          X_boot, y_boot = sk_utils.resample(X_train, y_train)
          # X_boot, y_boot = X_train[train_index], y_train[train_index]
  
          reg.fit(X_boot, y_boot)
          y_predict = reg.predict(X_test)
          y_pred_array[:, i_bs] = y_predict.ravel()
  
          r2_array[i_bs] = sk_metrics.r2_score(y_test, y_predict)
          # r2_array[i_bs] = metrics.r2(y_test, y_predict)
          # mse_array[i_bs] = sk_metrics.mean_squared_error(y_test, y_predict)
  
          beta_coefs.append(reg.coef_)
  
      # R^2 score, 1 - sum(y-y_approx)/sum(y-mean(y))
      r2 = np.mean(r2_array)
  
      # # Mean Square Error, mean((y - y_approx)**2)
      # _mse = np.mean((y_test.ravel() - y_pred_list)**2,
      #                axis=0, keepdims=True)
      # mse = np.mean(mse_array)
      _mse = np.mean((y_test - y_pred_array)**2,
                     axis=1, keepdims=True)
      mse = np.mean(_mse)
  
      # Bias, (y - mean(y_approx))^2
      _y_pred_mean = np.mean(y_pred_array, axis=1, keepdims=True)
      bias = np.mean((y_test - _y_pred_mean)**2)
  
      # Variance, var(y_approx)
      var = np.mean(np.var(y_pred_array, axis=1, keepdims=True))
  
      beta_coefs = np.asarray(beta_coefs)
  
      coef_var = np.asarray(beta_coefs).var(axis=0)
      coef_ = np.asarray(beta_coefs).mean(axis=0)
  
      X_pred_test = X_test
      y_pred = y_pred_array.mean(axis=1)
      y_pred_var = y_pred_array.var(axis=1)
  
      return {
          "r2": r2, "mse": mse, "bias": bias,
          "var": var, "diff": mse - bias - var,
          "coef": coef_, "coef_var": coef_var, "x_pred": X_test[:, 1],
          "y_pred": y_pred, "y_pred_var": y_pred_var}
code_tokens: def SKLearnBootstrap ( X_train , y_train , reg , N_bs , test_percent = 0.4 , X_test = None , y_test = None , shuffle = False ) : if ( ( isinstance ( X_test , type ( None ) ) ) and ( isinstance ( y_test , type ( None ) ) ) ) : X_train , X_test , y_train , y_test = sk_modsel . train_test_split ( X_train , y_train , test_size = test_percent , shuffle = shuffle ) y_pred_array = np . empty ( ( y_test . shape [ 0 ] , N_bs ) ) r2_array = np . empty ( N_bs ) mse_array = np . empty ( N_bs ) beta_coefs = [ ] for i_bs in tqdm ( range ( N_bs ) , desc = "SKLearnBootstrap" ) : X_boot , y_boot = sk_utils . resample ( X_train , y_train ) reg . fit ( X_boot , y_boot ) y_predict = reg . predict ( X_test ) y_pred_array [ : , i_bs ] = y_predict . ravel ( ) r2_array [ i_bs ] = sk_metrics . r2_score ( y_test , y_predict ) beta_coefs . append ( reg . coef_ ) r2 = np . mean ( r2_array ) _mse = np . mean ( ( y_test - y_pred_array ) ** 2 , axis = 1 , keepdims = True ) mse = np . mean ( _mse ) _y_pred_mean = np . mean ( y_pred_array , axis = 1 , keepdims = True ) bias = np . mean ( ( y_test - _y_pred_mean ) ** 2 ) var = np . mean ( np . var ( y_pred_array , axis = 1 , keepdims = True ) ) beta_coefs = np . asarray ( beta_coefs ) coef_var = np . asarray ( beta_coefs ) . var ( axis = 0 ) coef_ = np . asarray ( beta_coefs ) . mean ( axis = 0 ) X_pred_test = X_test y_pred = y_pred_array . mean ( axis = 1 ) y_pred_var = y_pred_array . var ( axis = 1 ) return { "r2" : r2 , "mse" : mse , "bias" : bias , "var" : var , "diff" : mse - bias - var , "coef" : coef_ , "coef_var" : coef_var , "x_pred" : X_test [ : , 1 ] , "y_pred" : y_pred , "y_pred_var" : y_pred_var }
short_docstring: A wrapper for the Scikit-Learn Bootstrap method.
short_docstring_tokens: A wrapper for the Scikit - Learn Bootstrap method .
comment: """
      A wrapper for the Scikit-Learn Bootstrap method.
      """$SEP$# Checks if we have provided test data or not$SEP$# Splits X data and design matrix data$SEP$# Storage containers for results$SEP$# for i_bs, val_ in enumerate(bs):$SEP$# X_boot, y_boot = X_train[train_index], y_train[train_index]$SEP$# r2_array[i_bs] = metrics.r2(y_test, y_predict)$SEP$# mse_array[i_bs] = sk_metrics.mean_squared_error(y_test, y_predict)$SEP$# R^2 score, 1 - sum(y-y_approx)/sum(y-mean(y))$SEP$# # Mean Square Error, mean((y - y_approx)**2)$SEP$# _mse = np.mean((y_test.ravel() - y_pred_list)**2,$SEP$#                axis=0, keepdims=True)$SEP$# mse = np.mean(mse_array)$SEP$# Bias, (y - mean(y_approx))^2$SEP$# Variance, var(y_approx)