Skip to content

Commit

Permalink
removed reference to deprecated sklearn.metrics.scorer
Browse files Browse the repository at this point in the history
  • Loading branch information
dpfoose committed Feb 12, 2020
1 parent d88a9fc commit 222aec4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pyopls/permutation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
from sklearn.base import is_classifier, clone, ClassifierMixin
from sklearn.exceptions import DataConversionWarning
from sklearn.metrics import r2_score, accuracy_score
from sklearn.metrics.scorer import _passthrough_scorer
from sklearn.model_selection import check_cv, cross_val_predict
from sklearn.utils import indexable, check_random_state


def passthrough_scorer(estimator, *args, **kwargs):
"""Function that wraps estimator.score"""
return estimator.score(*args, **kwargs)


def non_cv_permutation_test_score(estimator, X, y, groups=None,
n_permutations=100, n_jobs=None, random_state=0,
verbose=0, pre_dispatch='2*n_jobs', scorers=None):
Expand Down Expand Up @@ -112,7 +116,7 @@ def non_cv_permutation_test_score(estimator, X, y, groups=None,
random_state = check_random_state(random_state)
if scorers is None or not len(scorers):
if hasattr(estimator, 'score'):
scorers = [_passthrough_scorer]
scorers = [passthrough_scorer]
else:
raise TypeError(
"If no scoring is specified, the estimator passed should "
Expand Down

0 comments on commit 222aec4

Please sign in to comment.