'Evaluate decision function output for X relative to y_true.
Parameters
clf : object
Trained classifier to use for scoring. Must have either a
decision_function method or a predict_proba method; the output of
that is used to compute the score.
X : array-like or sparse matrix
Test data that will be fed to clf.decision_function or
clf.predict_proba.
y : array-like
Gold standard target values for X. These must be class labels,
not decision function values.
sample_weight : array-like, optional (default=None)
Sample weights.
Returns
score : float
Score function applied to prediction of estimator on X.'

def __call__(self, clf, X, y, sample_weight=None):

    super(_ThresholdScorer, self).__call__(clf, X, y, sample_weight=sample_weight)
    y_type = type_of_target(y)
    if (y_type not in ('binary', 'multilabel-indicator')):
        raise ValueError('{0}    format    is    not    supported'.format(y_type))
    if is_regressor(clf):
        y_pred = clf.predict(X)
    else:
        try:
            y_pred = clf.decision_function(X)
            if isinstance(y_pred, list):
                y_pred = np.vstack((p for p in y_pred)).T
        except (NotImplementedError, AttributeError):
            y_pred = clf.predict_proba(X)
            if (y_type == 'binary'):
                y_pred = y_pred[:, 1]
            elif isinstance(y_pred, list):
                y_pred = np.vstack([p[:, (-1)] for p in y_pred]).T
    if (sample_weight is not None):
        return (self._sign * self._score_func(y, y_pred, sample_weight=sample_weight, **self._kwargs))
    else:
        return (self._sign * self._score_func(y, y_pred, **self._kwargs))
