0
0
ML Pythonml~10 mins

Why deployment delivers value in ML Python - Test Your Understanding

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

Complete the code to print the model's prediction on new data.

ML Python
prediction = model.[1](new_data)
print(prediction)
Drag options to blanks, or click blank then click option'
Atransform
Bpredict
Cfit
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fit' instead of 'predict' to get predictions.
2fill in blank
medium

Complete the code to save the trained model for deployment.

ML Python
import joblib
joblib.[1](model, 'model.pkl')
Drag options to blanks, or click blank then click option'
Aload
Bsave
Cdump
Dexport
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'load' instead of 'dump' to save the model.
3fill in blank
hard

Fix the error in the code to deploy a model as a web service.

ML Python
from flask import Flask, request, jsonify
app = Flask(__name__)

@app.route('/predict', methods=['POST'])
def predict():
    data = request.get_json()
    prediction = model.[1](data['input'])
    return jsonify({'prediction': prediction.tolist()})
Drag options to blanks, or click blank then click option'
Afit
Bevaluate
Ctrain
Dpredict
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fit' or 'train' instead of 'predict' in deployment code.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that filters features with importance above 0.1.

ML Python
important_features = {feature: importance for feature, importance in model.feature_importances_.items() if importance [1] 0.1 and feature [2] 'bias'}
Drag options to blanks, or click blank then click option'
A>
B<
C!=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' for importance check.
Using '==' instead of '!=' to exclude 'bias'.
5fill in blank
hard

Fill all three blanks to create a dictionary of predictions for inputs with confidence above 0.8.

ML Python
high_confidence_preds = [1]: [2] for [3] in inputs if model.predict_proba([[3]])[0][1] > 0.8}
Drag options to blanks, or click blank then click option'
Ainput
Bmodel.predict([input])[0]
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Using predict_proba output directly as prediction.