Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to calculate accuracy score using sklearn.
ML Python
from sklearn.metrics import [1] accuracy = [1](y_true, y_pred) print(f"Accuracy: {accuracy:.2f}")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
2fill in blank
mediumComplete the code to calculate precision score for binary classification.
ML Python
from sklearn.metrics import precision_score precision = precision_score(y_true, y_pred, [1]=1) print(f"Precision: {precision:.2f}")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
3fill in blank
hardFix the error in the code to calculate recall score correctly.
ML Python
from sklearn.metrics import recall_score recall = recall_score(y_true, y_pred, average=[1]) print(f"Recall: {recall:.2f}")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
4fill in blank
hardFill both blanks to calculate F1 score with macro averaging.
ML Python
from sklearn.metrics import f1_score f1 = f1_score(y_true, y_pred, [1]=[2]) print(f"F1 Score: {f1:.2f}")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a dictionary of classification metrics.
ML Python
metrics = {
'accuracy': [1](y_true, y_pred),
'precision': [2](y_true, y_pred, average='macro'),
'recall': [3](y_true, y_pred, average='macro')
}
print(metrics) Drag options to blanks, or click blank then click option'
Attempts:
3 left