0
0
MLOpsdevops~10 mins

Automated model validation before promotion in MLOps - Interactive Code Practice

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

Complete the code to run model validation using a CI pipeline step.

MLOps
steps:
  - name: Validate Model
    run: python validate_model.py --model [1]
Drag options to blanks, or click blank then click option'
Alatest_model.pkl
Btrain.py
Cmodel.pkl
Ddeploy.sh
Attempts:
3 left
💡 Hint
Common Mistakes
Using a script file instead of the model file.
Using a deployment script instead of the model.
2fill in blank
medium

Complete the code to check if model accuracy meets the threshold before promotion.

MLOps
if accuracy [1] 0.85:
    print('Model passed validation')
else:
    print('Model failed validation')
Drag options to blanks, or click blank then click option'
A!=
B<
C==
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than operator which rejects good models.
Using equality which is too strict.
3fill in blank
hard

Fix the error in the validation script to correctly load the model file.

MLOps
with open('[1]', 'rb') as f:
    model = pickle.load(f)
Drag options to blanks, or click blank then click option'
Amodel.pkl
Bmodel.json
Cmodel.txt
Dmodel.py
Attempts:
3 left
💡 Hint
Common Mistakes
Using a text or JSON file which causes load errors.
Using a Python script file instead of a model file.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that filters models with accuracy above 0.9.

MLOps
high_accuracy_models = {model[1]: acc for model, acc in results.items() if acc [2] 0.9}
Drag options to blanks, or click blank then click option'
A.upper()
B>
C>=
D.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase instead of uppercase for model names.
Using >= instead of > which includes 0.9 exactly.
5fill in blank
hard

Fill all three blanks to create a dictionary of models with accuracy above 0.8 and keys as lowercase model names.

MLOps
validated_models = { [1]: [2] for [3] in results.items() if [2] > 0.8}
Drag options to blanks, or click blank then click option'
Amodel.lower()
Bacc
C(model, acc)
Daccuracy
Attempts:
3 left
💡 Hint
Common Mistakes
Incorrect iteration variable like 'model' instead of '(model, acc)'.
Using wrong variable names for iteration or values.