Precision and Recall: The Fisherman’s Guide to Classification Metrics

<p>Precision and recall are two important metrics used to evaluate the performance of classification models, especially when the class distribution is imbalanced. Let&rsquo;s break them down with a simple analogy and an example.</p> <h1>Analogy:</h1> <p>Imagine you are a fisherman using a net to catch fish in a pond. The fish in the pond represent the true positives (the things you want to catch), while any other objects like weeds, sticks, or trash represent the false positives (the things you don&rsquo;t want to catch).</p> <ul> <li>Precision: Of all the things you caught with your net, how many were actually fish? Precision measures the accuracy of your catch.</li> <li>Precision=Number of fish caughtTotal items caught (fish + other objects)Precision=Total items caught (fish + other objects)Number of fish caught​</li> </ul> <p><img alt="" src="https://miro.medium.com/v2/resize:fit:497/0*8_DKWyei5fZgoPc_" style="height:36px; width:497px" /></p> <ul> <li>Recall: Of all the fish in the pond, how many did you manage to catch? Recall measures how effectively you caught all the fish available.</li> <li>Recall=Number of fish caughtTotal fish in the pondRecall=Total fish in the pondNumber of fish caught​</li> </ul> <p><img alt="" src="https://miro.medium.com/v2/resize:fit:300/0*9Mb8YD77YqyHbJKn" style="height:35px; width:300px" /></p> <h1>Example:</h1> <p>Suppose you are building a model to detect spam emails. Let&rsquo;s look at the results in a simplified manner:</p> <ul> <li>True Positive (TP): Spam emails correctly identified as spam.</li> <li>False Positive (FP): Non-spam emails incorrectly identified as spam.</li> <li>True Negative (TN): Non-spam emails correctly identified as non-spam.</li> <li>False Negative (FN): Spam emails incorrectly identified as non-spam.</li> </ul> <p>Now, based on these definitions:</p> <ul> <li>Precision tells you how many of the emails you flagged as spam were actually spam. It&rsquo;s a measure of how &ldquo;precise&rdquo; your spam filter is.</li> </ul> <p><img alt="" src="https://miro.medium.com/v2/resize:fit:221/0*auVgAUmlBh7-d2r_" style="height:32px; width:221px" /></p> <p><a href="https://medium.com/@oojas2/precision-and-recall-the-fishermans-guide-to-classification-metrics-9054d478f4fa"><strong>Click Here</strong></a></p>