Complete the code to define a pipeline step that preprocesses data.
def preprocess_data(data): cleaned_data = data.[1]() return cleaned_data
The dropna() method removes missing values, which is a common preprocessing step.
Complete the code to add a training step in the ML pipeline.
def train_model(features, labels): model = SomeModel() model.[1](features, labels) return model
predict instead of fit.The fit() method trains the model using features and labels.
Fix the error in the pipeline step that evaluates the model.
def evaluate_model(model, test_features, test_labels): predictions = model.predict(test_features) accuracy = [1](test_labels, predictions) return accuracy
The correct function to calculate accuracy is accuracy_score from sklearn.metrics.
Fill both blanks to create a dictionary comprehension that maps features to their importance if importance is above 0.1.
important_features = {feature: importance for feature, importance in zip(model.feature_names_in_, model.[1]) if importance [2] 0.1}feature_importances_ holds feature importance values, and we filter those greater than 0.1.
Fill all three blanks to create a pipeline dictionary that stores model name, accuracy, and timestamp if accuracy is above 0.8.
pipeline_result = {
'[1]': model_name.upper(),
'accuracy': accuracy,
'timestamp': datetime.[2](),
}
if accuracy [3] 0.8:
save_result(pipeline_result)Use 'name' as the key for model name, datetime.now() for current time, and > to check accuracy above 0.8.