Your question is Classification Metrics Evaluation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
In InstaDeep's DeepChain model-evaluation workflow, implement a function that computes standard binary classification metrics from predicted labels and ground-truth labels. Return accuracy, precision, recall, and F1 score without using external machine-learning libraries.
Given two lists, predictions and labels, containing binary values, and an integer positive_label, return a dictionary with the floating-point keys accuracy, precision, recall, and f1.
Use these definitions:
accuracy = (TP + TN) / Nprecision = TP / (TP + FP)recall = TP / (TP + FN)f1 = 2 * precision * recall / (precision + recall)If a metric has a zero denominator, return 0.0 for that metric. In particular, F1 is 0.0 when both precision and recall are zero. The input lists are guaranteed to have equal, nonzero lengths.
def compute_classification_metrics(predictions, labels, positive_label):