Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to save a trained model using joblib.
ML Python
import joblib # Assume model is already trained joblib.[1](model, 'model.pkl')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'load' instead of 'dump' to save the model.
Using 'save' which is not a joblib function.
✗ Incorrect
The joblib.dump() function is used to save a model to a file.
2fill in blank
mediumComplete the code to load a saved model using joblib.
ML Python
import joblib model = joblib.[1]('model.pkl')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'dump' instead of 'load' to load the model.
Using 'save' which is not a joblib function.
✗ Incorrect
The joblib.load() function reads a saved model from a file.
3fill in blank
hardFix the error in saving a Keras model to HDF5 format.
ML Python
model.[1]('model.h5')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'dump' which is not a Keras model method.
Using 'load' instead of 'save'.
✗ Incorrect
Keras models are saved using the save() method.
4fill in blank
hardFill both blanks to load a Keras model and evaluate it.
ML Python
from tensorflow.keras.models import [1] model = [2]('model.h5') loss, accuracy = model.evaluate(x_test, y_test)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'save_model' which is for saving, not loading.
Using 'load' which is not imported from keras.models.
✗ Incorrect
The function load_model from Keras loads a saved model from a file.
5fill in blank
hardFill all three blanks to save a scikit-learn model, load it, and make predictions.
ML Python
import joblib joblib.[1](model, 'model.pkl') loaded_model = joblib.[2]('model.pkl') predictions = loaded_model.[3](X_test)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'save' instead of 'dump' to save the model.
Using 'load' incorrectly as a method on the model.
Using 'fit' instead of 'predict' to get predictions.
✗ Incorrect
Use dump to save, load to load, and predict to get model predictions.