0
0
ML Pythonml~10 mins

Model versioning 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 model using versioning.

ML Python
model.save('model_v[1].h5')
Drag options to blanks, or click blank then click option'
A1
Bbest
Cfinal
Dlatest
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings like 'latest' or 'best' without a number can cause confusion in versioning.
2fill in blank
medium

Complete the code to load a specific model version.

ML Python
loaded_model = load_model('model_v[1].h5')
Drag options to blanks, or click blank then click option'
A2
Blatest
Cfinal
Dbest
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-numeric strings like 'best' or 'latest' without a clear version number.
3fill in blank
hard

Fix the error in the code to properly save the model with versioning.

ML Python
model.save('model_[1].h5')
Drag options to blanks, or click blank then click option'
A1v
Bversion1
Cv1
Dver1
Attempts:
3 left
💡 Hint
Common Mistakes
Using '1v' or 'ver1' which are less clear or unconventional.
4fill in blank
hard

Fill both blanks to create a dictionary that maps model versions to their file paths.

ML Python
model_versions = {'v1': '[1]', 'v2': '[2]'}
Drag options to blanks, or click blank then click option'
Amodel_v1.h5
Bmodel_latest.h5
Cmodel_v2.h5
Dmodel_best.h5
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing version keys with unrelated file names like 'latest' or 'best'.
5fill in blank
hard

Fill all three blanks to load a model version from the dictionary and make a prediction.

ML Python
model_path = model_versions['[1]']
loaded_model = load_model(model_path)
prediction = loaded_model.predict([2])
print('Prediction for version [3]:', prediction)
Drag options to blanks, or click blank then click option'
Av2
Binput_data
Cv1
Dtest_data
Attempts:
3 left
💡 Hint
Common Mistakes
Using mismatched version keys or wrong data variable names.