Join Our 5-Week ML/AI Engineer Interview Bootcamp 🚀 led by ML Tech Leads at FAANGs
Evaluate a computer vision model using common metrics so you can compare predictions against ground-truth labels.
You’ll implement accuracy, precision, recall, and F1-score for a binary image classifier given lists of predicted labels and true labels.
Implement the function
Rules:
dict with the four metrics.sklearn.metrics).Output:
| Argument | Type |
|---|---|
| y_pred | np.ndarray |
| y_true | np.ndarray |
| Return Name | Type |
|---|---|
| value | dict |
No sklearn.metrics or prebuilt metric functions
Return Python float values, not NumPy scalars
Inputs are NumPy arrays, so you can compare all elements at once.
Compute confusion-matrix counts with boolean masks, e.g. tp = np.sum((y_true==1) & (y_pred==1)), similarly for TN/FP/FN.
Plug TP/TN/FP/FN into the given formulas, then return a dict with Python floats (wrap results with float(...)).