Complete the code to print the model's prediction on new data.
prediction = model.[1](new_data) print(prediction)
The predict method is used to get the model's output on new data.
Complete the code to save the trained model for deployment.
import joblib joblib.[1](model, 'model.pkl')
The dump function saves the model to a file for later use.
Fix the error in the code to deploy a model as a web service.
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()})
Use predict to get the model's output on input data in deployment.
Fill both blanks to create a dictionary comprehension that filters features with importance above 0.1.
important_features = {feature: importance for feature, importance in model.feature_importances_.items() if importance [1] 0.1 and feature [2] 'bias'}We want features with importance greater than 0.1 and exclude the 'bias' feature.
Fill all three blanks to create a dictionary of predictions for inputs with confidence above 0.8.
high_confidence_preds = [1]: [2] for [3] in inputs if model.predict_proba([[3]])[0][1] > 0.8}
We use 'input' as the key and the model's prediction as the value for each input in inputs.
