Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to save a trained pipeline using joblib.
ML Python
import joblib joblib.[1](pipeline, 'model_pipeline.pkl')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using joblib.load() instead of joblib.dump() to save the model.
Using joblib.save() which does not exist.
✗ Incorrect
The joblib.dump() function is used to save a pipeline or model to a file.
2fill in blank
mediumComplete the code to load a saved pipeline from a file using joblib.
ML Python
import joblib pipeline = joblib.[1]('model_pipeline.pkl')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using joblib.dump() instead of joblib.load() to load the model.
Using open() which does not load joblib objects.
✗ Incorrect
The joblib.load() function loads a saved pipeline or model from a file.
3fill in blank
hardFix the error in the code to save a pipeline using pickle.
ML Python
import pickle with open('pipeline.pkl', '[1]') as f: pickle.dump(pipeline, f)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Opening the file in text write mode 'w' causes errors.
Using read modes 'r' or 'rb' when writing.
✗ Incorrect
When saving with pickle, the file must be opened in binary write mode 'wb'.
4fill in blank
hardFill both blanks to load a pipeline saved with pickle.
ML Python
import pickle with open('pipeline.pkl', '[1]') as f: pipeline = pickle.[2](f)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Opening the file in write mode when loading.
Using pickle.dump() instead of pickle.load() to load.
✗ Incorrect
To load a pickle file, open it in binary read mode 'rb' and use pickle.load().
5fill in blank
hardFill all three blanks to save a pipeline using joblib with compression.
ML Python
import joblib joblib.[1](pipeline, 'compressed_pipeline.pkl', compress=[2], protocol=[3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using joblib.load() instead of dump() to save.
Using wrong compression or protocol values.
✗ Incorrect
Use joblib.dump() to save with compression level 5 and protocol 3 for compatibility.