8000 WIP Auc grid search by amueller · Pull Request #1014 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

WIP Auc grid search #1014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions sklearn/grid_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .cross_validation import check_cv
from .externals.joblib import Parallel, delayed, logger
from .utils import deprecated, check_arrays, safe_mask
from .metrics import average_precision_score, auc_score


class IterGrid(object):
Expand Down Expand Up @@ -111,7 +112,13 @@ def fit_grid_point(X, y, base_clf, clf_params, train, test, loss_func,
y_pred = clf.predict(X_test)
this_score = -loss_func(y_test, y_pred)
elif score_func is not None:
y_pred = clf.predict(X_test)
if score_func in [average_precision_score, auc_score]:
try:
y_pred = clf.decision_function(X_test)
except (AttributeError, NotImplementedError):
y_pred = clf.predict_proba(X_test)[:, 1]
else:
y_pred = clf.predict(X_test)
this_score = score_func(y_test, y_pred)
else:
this_score = clf.score(X_test, y_test)
Expand Down Expand Up @@ -452,7 +459,10 @@ def score(self, X, y=None):
raise ValueError("No score function explicitly defined, "
"and the estimator doesn't provide one %s"
% self.best_estimator_)
y_predicted = self.predict(X)
if self.score_func in [average_precision_score, auc_score]:
y_predicted = self.decision_function(X)
else:
y_predicted = self.predict(X)
return self.score_func(y, y_predicted)

# TODO around 0.13: remove this property, make it an attribute
Expand Down
0