0
0
ML Pythonml~10 mins

Monitoring model performance in ML Python - Interactive Code Practice

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

Complete the code to calculate the accuracy of a model's predictions.

ML Python
accuracy = [1](y_true, y_pred)
Drag options to blanks, or click blank then click option'
Amean_squared_error
Baccuracy_score
Clog_loss
Droc_auc_score
Attempts:
3 left
💡 Hint
Common Mistakes
Using mean_squared_error for classification accuracy
Confusing accuracy_score with log_loss
2fill in blank
medium

Complete the code to plot the model's loss over epochs using matplotlib.

ML Python
plt.plot(history.history['[1]'])
Drag options to blanks, or click blank then click option'
Aval_accuracy
Baccuracy
Closs
Dval_loss
Attempts:
3 left
💡 Hint
Common Mistakes
Plotting accuracy instead of loss
Using validation keys when plotting training loss
3fill in blank
hard

Fix the error in the code to compute the F1 score for binary classification.

ML Python
f1 = f1_score(y_true, [1], average='binary')
Drag options to blanks, or click blank then click option'
Ay_pred
By_true
Cy_score
Dy_prob
Attempts:
3 left
💡 Hint
Common Mistakes
Passing true labels twice
Using predicted probabilities instead of labels
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that tracks precision and recall for each class.

ML Python
metrics = {cls: {'precision': precision_score(y_true, y_pred, pos_label=cls), 'recall': [1](y_true, y_pred, pos_label=[2])} for cls in classes}
Drag options to blanks, or click blank then click option'
Arecall_score
Bprecision_score
Ccls
Dy_pred
Attempts:
3 left
💡 Hint
Common Mistakes
Using precision_score twice
Passing predicted labels as pos_label
5fill in blank
hard

Fill all three blanks to create a filtered dictionary of metrics where F1 score is above 0.7.

ML Python
filtered_metrics = {cls: metrics[cls] for cls in metrics if metrics[cls]['[1]'] [2] [3]
Drag options to blanks, or click blank then click option'
Af1_score
B>
C0.7
Dprecision
Attempts:
3 left
💡 Hint
Common Mistakes
Using precision instead of f1_score
Using wrong comparison operator
Using string '0.7' instead of number