class_docstr: Out-of-bag early stopping.
  
  A callable that returns True when the test error starts
  rising. We use a Spearman correlation (between X_test.w and y_test)
  for scoring.
class_docstr_tok: ["Out-of-bag","early","stopping",".","A","callable","that","returns","True","when","the","test","error","starts","rising",".","We","use","a","Spearman","correlation","(","between","X_test.w","and","y_test",")","for","scoring","."]
docstr: Compute test score for model, given weights map `w`.
  
  We use correlations between linear prediction and
  ground truth (y_test).
  
  We return 2 scores for model selection: one is the Spearman
  correlation, which captures ordering between input and
  output, but tends to have 'flat' regions. The other
  is the Pearson correlation, that we can use to disambiguate
  between regions with equivalent Spearman correlation.
docstr_tok: ["Compute","test","score","for","model",",","given","weights","map","`","w","`",".","We","use","correlations","between","linear","prediction","and","ground","truth","(","y_test",")",".","We","return","2","scores","for","model","selection",":","one","is","the","Spearman","correlation",",","which","captures","ordering","between","input","and","output",",","but","tends","to","have","'flat","'","regions",".","The","other","is","the","Pearson","correlation",",","that","we","can","use","to","disambiguate","between","regions","with","equivalent","Spearman","correlation","."]
code: def test_score(self, w):
      """Compute test score for model, given weights map `w`.
  
      We use correlations between linear prediction and
      ground truth (y_test).
  
      We return 2 scores for model selection: one is the Spearman
      correlation, which captures ordering between input and
      output, but tends to have 'flat' regions. The other
      is the Pearson correlation, that we can use to disambiguate
      between regions with equivalent Spearman correlation.
  
      """
      if self.is_classif:
          w = w[:-1]
      if np.ptp(w) == 0:
          # constant map, there is nothing
          return (-np.inf, -np.inf)
      y_pred = np.dot(self.X_test, w)
      spearman_score = stats.spearmanr(y_pred, self.y_test)[0]
      pearson_score = np.corrcoef(y_pred, self.y_test)[1, 0]
      if self.is_classif:
          return spearman_score, pearson_score
      else:
          return pearson_score, spearman_score
  
imports: import collections
  import sys
  import time
  import warnings
  from functools import partial
  import numpy
  from joblib import Memory, Parallel, delayed
  from scipy import stats
  from scipy.ndimage import binary_dilation, binary_erosion, gaussian_filter
  from sklearn.feature_selection import SelectPercentile, f_classif, f_regression
  from sklearn.linear_model import LinearRegression
  from sklearn.linear_model._base import _preprocess_data
  from sklearn.metrics import accuracy_score
  from sklearn.model_selection import check_cv
  from sklearn.preprocessing import LabelBinarizer
  from sklearn.utils import check_array, check_X_y
  from sklearn.utils.extmath import safe_sparse_dot
  from nilearn._utils.masker_validation import check_embedded_masker
  from nilearn.experimental.surface import SurfaceMasker
  from nilearn.image import get_data
  from nilearn.masking import unmask_from_to_3d_array
  from .._utils import fill_doc
  from .._utils.cache_mixin import CacheMixin
  from .._utils.param_validation import adjust_screening_percentile
  from .space_net_solvers import graph_net_logistic, graph_net_squared_loss, tvl1_solver
label_desc: Use image node_id 4 for calling the _EarlyStoppingCallback obj's underlying member method code with example usage: obj.test_score(w) and returns: unknown,  unknown, spearman_score,  pearson_score, pearson_score,  spearman_score