0
0
MLOpsdevops~10 mins

Batch prediction vs real-time serving in MLOps - Interactive Practice

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

Complete the code to perform batch prediction on a dataset using a trained model.

MLOps
predictions = model.[1](X_batch)
Drag options to blanks, or click blank then click option'
Atransform
Bfit
Cpredict
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using fit instead of predict.
Using transform which is for feature transformations.
2fill in blank
medium

Complete the code to serve a real-time prediction request using a deployed model.

MLOps
def serve_request(input_data):
    prediction = model.[1](input_data)
    return prediction
Drag options to blanks, or click blank then click option'
Apredict
Bevaluate
Ctrain
Dfit
Attempts:
3 left
💡 Hint
Common Mistakes
Using fit or train instead of predict.
Using evaluate which is for testing model performance.
3fill in blank
hard

Fix the error in the batch prediction code by completing the blank.

MLOps
batch_predictions = model.predict([1])
Drag options to blanks, or click blank then click option'
Afit
By_batch
Cmodel
DX_batch
Attempts:
3 left
💡 Hint
Common Mistakes
Passing labels y_batch to predict.
Passing the model itself or calling fit instead.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps input IDs to their batch predictions.

MLOps
id_to_prediction = {id: [1] for id, [2] in zip(ids, batch_data)}
Drag options to blanks, or click blank then click option'
Amodel.predict([batch_data])
Bmodel.predict({{BLANK_2}})
Cdata
Dfeatures
Attempts:
3 left
💡 Hint
Common Mistakes
Using model.predict([batch_data]) which passes a list of the whole batch.
Using a wrong variable name for the batch item.
5fill in blank
hard

Fill all three blanks to complete the real-time serving function that preprocesses input, predicts, and returns the result.

MLOps
def serve(input_raw):
    processed = [1](input_raw)
    prediction = model.[2](processed)
    return [3]
Drag options to blanks, or click blank then click option'
Apreprocess
Bpredict
Cprediction
Dtransform
Attempts:
3 left
💡 Hint
Common Mistakes
Returning the processed data instead of the prediction.
Using transform instead of predict for model output.