0
0
MLOpsdevops~10 mins

Why pipelines automate the ML workflow in MLOps - Test Your Understanding

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

Complete the code to define a pipeline step that preprocesses data.

MLOps
def preprocess_data(data):
    cleaned_data = data.[1]()
    return cleaned_data
Drag options to blanks, or click blank then click option'
Aremove
Bfilter
Cdropna
Dclean
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method that does not exist on the data object.
Trying to filter instead of dropping missing values.
2fill in blank
medium

Complete the code to add a training step in the ML pipeline.

MLOps
def train_model(features, labels):
    model = SomeModel()
    model.[1](features, labels)
    return model
Drag options to blanks, or click blank then click option'
Apredict
Bfit_transform
Ctrain
Dfit
Attempts:
3 left
💡 Hint
Common Mistakes
Using predict instead of fit.
Using a method that transforms data instead of training.
3fill in blank
hard

Fix the error in the pipeline step that evaluates the model.

MLOps
def evaluate_model(model, test_features, test_labels):
    predictions = model.predict(test_features)
    accuracy = [1](test_labels, predictions)
    return accuracy
Drag options to blanks, or click blank then click option'
Aaccuracy_score
Bevaluate_accuracy
Cscore_accuracy
Dcalc_accuracy
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent function name.
Confusing evaluation function names.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps features to their importance if importance is above 0.1.

MLOps
important_features = {feature: importance for feature, importance in zip(model.feature_names_in_, model.[1]) if importance [2] 0.1}
Drag options to blanks, or click blank then click option'
Afeature_importances_
B>
C<
Dcoef_
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong attribute for feature importance.
Using less than instead of greater than in the condition.
5fill in blank
hard

Fill all three blanks to create a pipeline dictionary that stores model name, accuracy, and timestamp if accuracy is above 0.8.

MLOps
pipeline_result = {
    '[1]': model_name.upper(),
    'accuracy': accuracy,
    'timestamp': datetime.[2](),
}
if accuracy [3] 0.8:
    save_result(pipeline_result)
Drag options to blanks, or click blank then click option'
Amodel
Bnow
C>
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong dictionary keys.
Using incorrect datetime method.
Using wrong comparison operator.