top of page

Cracking ML Metrics - The Mnemonic Way!


In the complex landscape of machine learning, grasping concepts like false positives (type 1 error) and false negatives (type 2 error) can be daunting. Yet, these metrics play a crucial role in the evaluation of machine learning models, warranting a thorough understanding for effective implementation. Let’s embark on a journey to demystify these concepts and equip ourselves with the knowledge to navigate them adeptly.


Despite the widespread adoption of machine learning in the software industry, achieving a nuanced understanding of these metrics remains a challenge for many professionals. Formal definitions and mathematical formulas abound, yet practical application often proves elusive. Engineers and data scientists frequently find themselves grappling with questions such as, "In what contexts are false negatives (or false positives) unacceptable?" or "Should my machine learning model prioritize higher precision or recall?"


Recognizing this common struggle, I endeavored to devise a mnemonic device that could simplify these concepts without compromising on accuracy.


You have a machine learning model that is supposed to predict something. Also, consider

  1. "TRUE" being the synonym for "Yes" or "Positive".

  2. "FALSE" being the synonym for "No" or "Negative".

  3. True positives and True negatives are self-explanatory. We will only focus on how to pick up "false negatives" and "false positives" - quickly (i.e. where the predicted and actuals are a mismatch).

Knowing this, follow below steps (we will go run this template through several examples later to make this concrete) -

  1. Statement: My model is supposed to predict <something>.

  2. Did your model predict <something>? TRUE/FALSE

  3. Was it really <something>? TRUE/FALSE

  4. If #2 and #3 is match in its values:

    1. "FALSE" remains constant in the outcome (as already deviated from the actual result)

    2. If prediction is FALSE and FALSE is Negative (from our consideration above), Outcome: FALSE NEGATIVE

    3. If prediction is TRUE and TRUE is Positive (from our consideration above) -> Outcome: FALSE POSITIVE

  5. FALSE NEGATIVE implies actual value was TRUE (Negate the value after FALSE <NEGATIVE/POSITIVE>). Similarly for FALSE POSITIVE, actual value is FALSE. You will see why this becomes more important in business sense.


Now, if above seems overwhleming - don't worry, just be with me for a while. This will all become very simple as we run through some real-life business cases. (Last thing I want to do is confuse you more!).


Let's consider below real-life example business cases based on above template.


Cancer detection

  1. Statement: My model is supposed to predict "cancer".

  2. Did your model predict "cancer"? FALSE.

  3. Was it really "cancer"? TRUE.

  4. Mismatch values. Meaning FALSE NEGATIVE. My scenario cannot tolerate where "cancer" is TRUE but prediction was FALSE (a.k.a. No tolerance for FALSE NEGATIVES which makes sense for the healthcare).


Credit card fraud detection

  1. Statement: My model is supposed to predict "credit card fraud".

  2. Did your model predict "credit card fraud"? FALSE.

  3. Was it really "credit card fraud"? TRUE.

  4. Mismatch values. Meaning FALSE NEGATIVE.


My scenario cannot tolerate where "credit card fraud" is TRUE but prediction was FALSE (a.k.a. No FALSE NEGATIVES which makes sense for frauds in financial services).


Spam email detection

  1. Statement: My model is supposed to predict "spam email".

  2. Did your model predict "spam email"? TRUE.

  3. Was it really "spam email"? FALSE.

  4. Mismatch values. Meaning FALSE POSITIVE.


My scenario cannot tolerate where "spam email" is FALSE but prediction was TRUE (a.k.a. No FALSE POSITIVES which makes sense as important mails should not land up in spam folders).


Ability of a person to repay debt

  1. Statement: My model is supposed to predict "ability of a person to repay debt".

  2. Did your model predict "ability of person to repay debt"? TRUE.

  3. Was it really "ability of person to repay debt"? FALSE.

  4. Mismatch values. Meaning FALSE POSITIVE. My scenario cannot tolerate where "ability of person to repay debt" is FALSE but prediction was TRUE (a.k.a. No FALSE POSITIVES which makes sense as especially in loan approval business).

Well, what do you think? This may need a little bit of practice but once you fit this template in your mind, you won't get confused on this - ever!


Armed with this knowledge, there's another metric which follows its natural course from above. Whether my model, based on my business, should focus more on "Recall" or "Precision"?


Recall the formulae -

  1. Precision - True Positives / (True Positives + False Positives)

  2. Recall - True Positives / (True Positives + False Negatives)

Tip:

  1. Another natural and easy to remember above formulae is, both are for accuracy calculations and for accuracy - "true positives" are important. So, it becomes our numerator as well one of the value in denominator.

  2. Now for another value in the demonitor for addition, if it's a "Precision", P for positive so "false positive". Of-course then, reverse for recall.


If my business cannot tolerate FALSE NEGATIVES, implies -

  1. FALSE NEGATIVES should be low.

  2. It appears in the denominator of Recall formula i.e. inversely proportional.

Recall should be High!


If my business cannot tolerate FALSE POSITIVES, implies -

  1. FALSE POSITIVES should be low.

  2. It appears in the denominator of Precision formula i.e. inversely proportional.

Precision should be High!


In conclusion, the mnemonic method offers a potent strategy for grasping the nuances of machine learning metrics like false positives and false negatives. By integrating this approach into their learning process, professionals can achieve a deeper understanding of these concepts, enabling informed decision-making in real-world applications.

Embracing mnemonic techniques not only simplifies complex concepts but also fosters mastery and proficiency in the field of machine learning.

5 views0 comments

Comentários


bottom of page