All our Data Science projects include bite-sized activities to test your knowledge and practice in an environment with constant feedback.
All our activities include solutions with explanations on how they work and why we chose them.
A spam recognition classifier is described by the following confusion matrix:
TP, TN, FP, FN = 4, 91, 1, 4
Compute the accuracy and insert the answer in the box below.
Round to two significant decimals
A spam recogition classifier is described by the following confusion matrix:
TP, TN, FP, FN = 0, 95, 5, 0
Compute the accuracy and insert the answer in the box below.
Round to two significant decimals
Compute the precision based on the following results:
TP = 114 FP = 14
Round to two significant decimals
Compute the recall based on the following results:
TP = 114 FN = 0
Round to two significant decimals.
Compute the F1- score based on the following results:
TP, FP, FN = 2.00, 1.00, 90.00
Round to two significant decimals
Let's now evaluate another example of how you could calculate some evaluation metrics.
# True labels of the data
y_true = [0, 1, 0, 1, 1, 0, 1, 1, 0, 0]
# Predicted labels of the data
y_pred = [0, 1, 0, 1, 0, 1, 1, 0, 1, 0]
Store the result in the variables f1
,accuracy
,precision
and recall
.
X_train = [[4,2,1],[3,4,6],[5,6,7],[8,9,7]]
y_train = [1,2,1,2]
X_test = [[4,3,1],[2,4,3],[5,6,1],[5,9,9]]
y_test = [1,2,2,2]
Use random_state=0 in the model and average='weighted'to calculate the precision. round to two decimal places the result.
X_train = [[4,2,1],[3,4,6],[5,6,7],[8,9,7]]
y_train = [1,2,1,2]
X_test = [[4,3,1],[2,4,3],[5,6,1],[5,9,9]]
y_test = [1,2,2,2]
Use random_state=0 in the model and average='weighted'to calculate the recall. round to two decimal places the result.
from sklearn.datasets import make_blobs
X_train, y_train = make_blobs(n_samples=100, centers=2,
random_state=0, cluster_std=2.3)
X_test, y_test = make_blobs(n_samples=10, centers=2,
random_state=0, cluster_std=4.5)
Use random_state=0 in the model and average='weighted'to calculate the F1-score. round to two decimal places the result.
Let’s say we have a machine that classifies if a fruit is an apple or not.