Skip to content

Replicating SelectKBest + GridSearchCV results #19674

Answered by NicolasHug
hex808080 asked this question in Q&A
Discussion options

You must be logged in to vote

The difference between the 2 snippets is in how auc is computed. I haven't doubled checked but I would bet that decision_function is used in GridSearch, while you're using calibrated probabilities (probabilities=True) in the for loop.

Change this:

        # y_pred = clf.predict_proba(anova.transform(X_test))[:, 1]
        y_pred = clf.decision_function(anova.transform(X_test))

and you'll get the same results.

For a better code: also remove probabilities=True everywhere (and also remove passing random_state to the estimators): you don't need the probabilities to compute the AUC, the output of the decision_function is enough.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@lesteve
Comment options

@hex808080
Comment options

@lesteve
Comment options

@NicolasHug
Comment options

Answer selected by lesteve
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants