0
0
Computer Visionml~10 mins

Model evaluation best practices in Computer Vision - 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 classification model.

Computer Vision
accuracy = accuracy_score(y_true, [1])
Drag options to blanks, or click blank then click option'
Ay_train
By_test
Cy_pred
Dy_val
Attempts:
3 left
💡 Hint
Common Mistakes
Using training labels instead of predicted labels.
Confusing true labels with predicted labels.
2fill in blank
medium

Complete the code to split the dataset into training and testing sets.

Computer Vision
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=[1], random_state=42)
Drag options to blanks, or click blank then click option'
A0.25
B0.5
C0.1
D0.75
Attempts:
3 left
💡 Hint
Common Mistakes
Setting test_size too high, leaving too little training data.
Using an integer instead of a float for test_size.
3fill in blank
hard

Fix the error in the code to compute the confusion matrix correctly.

Computer Vision
cm = confusion_matrix(y_true, [1])
Drag options to blanks, or click blank then click option'
Ay_train
By_test
Cy_val
Dy_pred
Attempts:
3 left
💡 Hint
Common Mistakes
Using test labels instead of predicted labels.
Mixing training labels with true labels.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each class to its precision score.

Computer Vision
precision_scores = {cls: precision_score(y_true, y_pred, labels=[cls], average=[1]) for cls in [2]
Drag options to blanks, or click blank then click option'
Amacro
Bmicro
Cweighted
Dclasses
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'micro' average which aggregates globally.
Using an undefined variable instead of class labels.
5fill in blank
hard

Fill all three blanks to compute the F1 score with macro averaging and print the result.

Computer Vision
f1 = f1_score(y_true, [1], average=[2])
print('F1 Score:', [3])
Drag options to blanks, or click blank then click option'
Ay_pred
Bmicro
Cf1
Dmacro
Attempts:
3 left
💡 Hint
Common Mistakes
Using micro average which aggregates globally.
Printing the wrong variable.