1. Home
  2. Data Science
  3. Scikit-learn
  4. What is the standard way to persist a fitted scikit-learn…

Added 30 Nov -0001

What is the standard way to persist a fitted scikit-learn estimator to disk?

  1. Copy the estimator class definition into a new module
  2. Serialise it with joblib.dump and restore it with joblib.load Correct answer
  3. Call model.save and reopen the file with Model.from_file
  4. Print the model and rebuild it from the console output

Correct answer

B. Serialise it with joblib.dump and restore it with joblib.load

16 views

MCQSEXAM

Explanation

joblib.dump serialises the fitted estimator along with every learned parameter and array, and joblib.load rebuilds it so predict can be called without retraining. scikit-learn deliberately exposes no save or load method on the estimators, because pickling the whole object is the supported route. A model restored this way must be read with the same library versions, since a changed attribute layout can break the unpickled object.

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