code: def y_score(estimator, X):
      
      try:
          y = estimator.predict_proba(X)
          return y[:, 1]
      except(AttributeError):
          return estimator.decision_function(X)
docs: Score examples from a new matrix X
      Args:
          estimator: an sklearn estimator object
          X: design matrix with the same features that the estimator was trained on
  
      Returns: a vector of scores of the same length as X
  
      Note that estimator.predict_proba is preferred but when unavailable
      (e.g. SVM without probability calibration) decision_function is used.