0
0
ML Pythonml~10 mins

Saving pipelines (joblib, pickle) in ML Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Awrite
Bsave
Cdump
Dload
Attempts:
3 left
💡 Hint
Common Mistakes
Using joblib.load() instead of joblib.dump() to save the model.
Using joblib.save() which does not exist.
2fill in blank
medium

Complete 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'
Adump
Bload
Csave
Dopen
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.
3fill in blank
hard

Fix 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'
Awb
Br
Cw
Drb
Attempts:
3 left
💡 Hint
Common Mistakes
Opening the file in text write mode 'w' causes errors.
Using read modes 'r' or 'rb' when writing.
4fill in blank
hard

Fill 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'
Arb
Bwb
Cload
Ddump
Attempts:
3 left
💡 Hint
Common Mistakes
Opening the file in write mode when loading.
Using pickle.dump() instead of pickle.load() to load.
5fill in blank
hard

Fill 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'
Adump
Bload
C3
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using joblib.load() instead of dump() to save.
Using wrong compression or protocol values.