1. Home
  2. Data Science
  3. Scikit-learn
  4. A modeller runs cross_val_predict(model, X, y, cv=5) and…

Added 30 Nov -0001

A modeller runs cross_val_predict(model, X, y, cv=5) and then computes accuracy on the returned predictions in order to select hyperparameters. What is the main objection?

  1. It requires a separate hold-out set and raises NotFittedError when none is supplied alongside cv
  2. The predictions are out-of-fold, but the same folds would also drive selection, so the resulting score is not a clean estimate Correct answer
  3. cross_val_predict refits on the full dataset first, so every prediction is in-sample and therefore over-optimistic
  4. It returns one aggregate score per fold instead of predictions, so accuracy cannot be computed from its output

Correct answer

B. The predictions are out-of-fold, but the same folds would also drive selection, so the resulting score is not a clean estimate

12 views

MCQSEXAM

Explanation

cross_val_predict returns predictions of the same shape as y, each produced by a model that never trained on that sample, which makes it useful for confusion matrices and residual inspection. It is not a scoring function, though, because choosing hyperparameters from those predictions reintroduces selection bias across the same folds; cross_val_score returns per-fold scores, and GridSearchCV or nested cross-validation keeps selection and estimation separate. Coverage can also be incomplete for some group or time-series splitters.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Scikit-learn MCQs

Practise all Scikit-learn MCQs

Similar MCQs