0
0
ML Pythonprogramming~20 mins

Confusion matrix in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Confusion Matrix Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
Understanding Confusion Matrix Components

Which part of the confusion matrix represents the number of times the model correctly predicted the positive class?

AFalse Positive (FP)
BTrue Positive (TP)
CTrue Negative (TN)
DFalse Negative (FN)
Attempts:
2 left
Predict Output
intermediate
1:30remaining
Output of Confusion Matrix Calculation

What is the output of the following Python code that computes a confusion matrix?

ML Python
from sklearn.metrics import confusion_matrix
true_labels = [1, 0, 1, 1, 0, 0, 1]
pred_labels = [1, 0, 0, 1, 0, 1, 1]
cm = confusion_matrix(true_labels, pred_labels)
print(cm.tolist())
A[[2, 1], [1, 3]]
B[[3, 0], [2, 2]]
C[[2, 0], [2, 3]]
D[[1, 2], [1, 3]]
Attempts:
2 left
Metrics
advanced
1:30remaining
Calculating Accuracy from Confusion Matrix

Given a confusion matrix [[50, 10], [5, 35]], what is the accuracy of the model?

A0.85
B0.75
C0.80
D0.90
Attempts:
2 left
🔧 Debug
advanced
1:00remaining
Identifying Error in Confusion Matrix Calculation

What error will the following code raise?

ML Python
from sklearn.metrics import confusion_matrix
true = [1, 0, 1]
pred = [1, 0]
cm = confusion_matrix(true, pred)
print(cm)
AIndexError: list index out of range
BTypeError: 'int' object is not iterable
CValueError: Found input variables with inconsistent numbers of samples
DNo error, prints confusion matrix
Attempts:
2 left
Model Choice
expert
2:00remaining
Choosing the Best Metric for Imbalanced Data

You have a dataset with 95% negative and 5% positive samples. Which confusion matrix derived metric is best to evaluate your model's ability to detect positives?

ASpecificity
BPrecision
CAccuracy
DRecall (Sensitivity)
Attempts:
2 left