If I want to optimise the regularisation parameter for a logistic regression model (for example) based on area under the ROC curve, I can use GridSearchCV
for a suitable range of parameters and set scoring='roc_auc'
.
This can be done using from sklearn.model_selection import GridSearchCV
, and there is no need to include from sklearn.metrics import roc_auc_score
.
However, if I want to calculate the area under the ROC curve manually for a particular fitted dataset then I do need to include from sklearn.metrics import roc_auc_score
.
- How does this work? I assume that by importing
GridSearchCV
we are somehow importingroc_auc_score
behind the scenes? Unfortunately I can't seem to follow this through in the source code - I'd really appreciate an explanation. - If this is the case, does it also mean that by importing
GridSearchCV
we end up importing all possible scoring methods behind the scenes? - Why then can I not use
roc_auc_score
"manually" myself if I have importedGridSearchCV
only and notroc_auc_score
itself? Is it not implicitly "there" behind the scenes?
I appreciate this may be a more general question about python importing and not specific to scikit-learn...