{"id":112,"date":"2024-05-02T22:04:00","date_gmt":"2024-05-02T22:04:00","guid":{"rendered":"https:\/\/amirhooshang.com\/blog\/?p=112"},"modified":"2025-05-17T22:43:07","modified_gmt":"2025-05-17T22:43:07","slug":"machine-learning-metrics-in-ensemble-learning-a-simple-relatable-guide","status":"publish","type":"post","link":"https:\/\/amirhooshang.com\/blog\/2024\/05\/02\/machine-learning-metrics-in-ensemble-learning-a-simple-relatable-guide\/","title":{"rendered":"Machine Learning Metrics in Ensemble Learning: A Simple, Relatable Guide"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"><strong>Introduction: Why Should You Care About Evaluation Metrics?<\/strong><\/h3>\n\n\n\n<p> Imagine you and your friends start a band. Each of you plays a different instrument, but together, you create a flawless song. That\u2019s exactly what <strong>Ensemble Learning<\/strong> does\u2014it combines multiple machine learning models to make better predictions. But here\u2019s the catch: How do you know if your &#8220;band&#8221; is actually good? This is where <strong>evaluation metrics<\/strong> like Accuracy, Precision, Recall, and F1-Score come into play. In this article, we\u2019ll break down these metrics in plain English, using relatable examples, so you\u2019ll never get stuck wondering which one to use. Let\u2019s dive in!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Evaluation Metrics Explained: From Accuracy to Log Loss<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1. Accuracy: It\u2019s Not What You Think!<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>What is it?<\/strong> If you score 95\/100 on a test, your accuracy is 95%. In machine learning, it\u2019s the same: the ratio of correct predictions to total predictions.<\/li>\n\n\n\n<li><strong>Formula:<\/strong><br><p class=\"ql-center-displayed-equation\" style=\"line-height: 37px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/amirhooshang.com\/blog\/wp-content\/ql-cache\/quicklatex.com-73503a1c2cb2def219bb2885c26a5491_l3.png\" height=\"37\" width=\"249\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#92;&#116;&#101;&#120;&#116;&#123;&#65;&#99;&#99;&#117;&#114;&#97;&#99;&#121;&#125;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#116;&#101;&#120;&#116;&#123;&#67;&#111;&#114;&#114;&#101;&#99;&#116;&#32;&#80;&#114;&#101;&#100;&#105;&#99;&#116;&#105;&#111;&#110;&#115;&#125;&#125;&#123;&#92;&#116;&#101;&#120;&#116;&#123;&#84;&#111;&#116;&#97;&#108;&#32;&#80;&#114;&#101;&#100;&#105;&#99;&#116;&#105;&#111;&#110;&#115;&#125;&#125;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p><\/li>\n\n\n\n<li><strong>Fun Example:<\/strong> Say your model classifies dog vs. cat images. If it correctly labels 90 out of 100 images, its accuracy is 90%. <strong>But beware!<\/strong> If 95% of the images are cats and the model just labels everything as &#8220;cat,&#8221; it\u2019ll still have 95% accuracy. That\u2019s why accuracy can be misleading for imbalanced data!<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2. Precision: The &#8220;No False Alarms&#8221; Expert<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>What is it?<\/strong> Precision answers: &#8220;Of all the times the model said \u2018positive,\u2019 how many were <em>actually<\/em> positive?&#8221; For example, if a spam filter labels 100 emails as spam but only 80 are truly spam, Precision is 80%.<\/li>\n\n\n\n<li><strong>Formula:<\/strong><br><p class=\"ql-center-displayed-equation\" style=\"line-height: 39px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/amirhooshang.com\/blog\/wp-content\/ql-cache\/quicklatex.com-c1a33bebfdb231f8d190a57b0b63ad6f_l3.png\" height=\"39\" width=\"344\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#92;&#116;&#101;&#120;&#116;&#123;&#80;&#114;&#101;&#99;&#105;&#115;&#105;&#111;&#110;&#125;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#116;&#101;&#120;&#116;&#123;&#84;&#114;&#117;&#101;&#32;&#80;&#111;&#115;&#105;&#116;&#105;&#118;&#101;&#115;&#125;&#125;&#123;&#92;&#116;&#101;&#120;&#116;&#123;&#84;&#114;&#117;&#101;&#32;&#80;&#111;&#115;&#105;&#116;&#105;&#118;&#101;&#115;&#32;&#43;&#32;&#70;&#97;&#108;&#115;&#101;&#32;&#80;&#111;&#115;&#105;&#116;&#105;&#118;&#101;&#115;&#125;&#125;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p><\/li>\n\n\n\n<li><strong>Real-Life Scenario:<\/strong> If your spam filter mistakenly flags your boss\u2019s email as spam (a <strong>False Positive<\/strong>), you\u2019re in trouble! Precision matters most when False Positives are costly.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>3. Recall: The &#8220;Leave No Stone Unturned&#8221; Detective<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>What is it?<\/strong> Recall asks: &#8220;Of all the <em>actual<\/em> positives, how many did the model catch?&#8221; If there are 100 cancer patients and the model detects 90, Recall is 90%.<\/li>\n\n\n\n<li><strong>Formula:<\/strong><br><p class=\"ql-center-displayed-equation\" style=\"line-height: 41px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/amirhooshang.com\/blog\/wp-content\/ql-cache\/quicklatex.com-a485381f707d75291e9a302dddec400e_l3.png\" height=\"41\" width=\"328\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#92;&#116;&#101;&#120;&#116;&#123;&#82;&#101;&#99;&#97;&#108;&#108;&#125;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#116;&#101;&#120;&#116;&#123;&#84;&#114;&#117;&#101;&#32;&#80;&#111;&#115;&#105;&#116;&#105;&#118;&#101;&#115;&#125;&#125;&#123;&#92;&#116;&#101;&#120;&#116;&#123;&#84;&#114;&#117;&#101;&#32;&#80;&#111;&#115;&#105;&#116;&#105;&#118;&#101;&#115;&#32;&#43;&#32;&#70;&#97;&#108;&#115;&#101;&#32;&#78;&#101;&#103;&#97;&#116;&#105;&#118;&#101;&#115;&#125;&#125;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p><\/li>\n\n\n\n<li><strong>High-Stakes Example:<\/strong> A cancer screening model with low Recall misses real patients (<strong>False Negatives<\/strong>), risking lives. In medicine, Recall is a big deal!<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>4. F1-Score: The Best of Both Worlds<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>What is it?<\/strong> A harmonic mean of Precision and Recall. It balances &#8220;fewer mistakes&#8221; (Precision) and &#8220;missing fewer positives&#8221; (Recall).<\/li>\n\n\n\n<li><strong>Formula:<\/strong><br><p class=\"ql-center-displayed-equation\" style=\"line-height: 38px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/amirhooshang.com\/blog\/wp-content\/ql-cache\/quicklatex.com-46dba0dab6a9311e06c3275547d33099_l3.png\" height=\"38\" width=\"216\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#92;&#116;&#101;&#120;&#116;&#123;&#70;&#49;&#125;&#32;&#61;&#32;&#50;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#116;&#101;&#120;&#116;&#123;&#80;&#114;&#101;&#99;&#105;&#115;&#105;&#111;&#110;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#116;&#101;&#120;&#116;&#123;&#82;&#101;&#99;&#97;&#108;&#108;&#125;&#125;&#123;&#92;&#116;&#101;&#120;&#116;&#123;&#80;&#114;&#101;&#99;&#105;&#115;&#105;&#111;&#110;&#125;&#32;&#43;&#32;&#92;&#116;&#101;&#120;&#116;&#123;&#82;&#101;&#99;&#97;&#108;&#108;&#125;&#125;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p><\/li>\n\n\n\n<li><strong>Use Case:<\/strong> If Precision is 70% and Recall is 90%, the F1-Score is ~78%. This tells you how well the model balances both metrics.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>5. ROC-AUC: The All-Rounder Metric<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>What is it?<\/strong> A graph showing model performance across all classification thresholds. AUC (Area Under the Curve) closer to 1 means better performance.<\/li>\n\n\n\n<li><strong>Visual Example:<\/strong> For a dog vs. cat classifier, an AUC of 0.95 means the model almost always distinguishes between the two.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>6. Log Loss: The &#8220;Confidence Penalty&#8221;<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>What is it?<\/strong> Penalizes the model for being overly confident but wrong. For example, if the model predicts &#8220;spam&#8221; with 90% confidence but is wrong, Log Loss skyrockets.<\/li>\n\n\n\n<li><strong>Formula:<\/strong><br><p class=\"ql-center-displayed-equation\" style=\"line-height: 52px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/amirhooshang.com\/blog\/wp-content\/ql-cache\/quicklatex.com-51646cee287eb53c4dd9f4c5316c4ed8_l3.png\" height=\"52\" width=\"403\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#92;&#116;&#101;&#120;&#116;&#123;&#76;&#111;&#103;&#32;&#76;&#111;&#115;&#115;&#125;&#32;&#61;&#32;&#45;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#78;&#125;&#32;&#92;&#115;&#117;&#109;&#95;&#123;&#105;&#61;&#49;&#125;&#94;&#123;&#78;&#125;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#32;&#121;&#95;&#105;&#32;&#92;&#108;&#111;&#103;&#40;&#112;&#95;&#105;&#41;&#32;&#43;&#32;&#40;&#49;&#45;&#121;&#95;&#105;&#41;&#32;&#92;&#108;&#111;&#103;&#40;&#49;&#45;&#112;&#95;&#105;&#41;&#32;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p><\/li>\n\n\n\n<li><strong>Simple Interpretation:<\/strong> A Log Loss of 0.1 means the model is highly confident <em>and<\/em> accurate. A score of 0.5? Not so much.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>When to Use Which Metric?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Scenario 1: Imbalanced Data<\/strong><\/li>\n\n\n\n<li>Example: 99% of credit card transactions are legit, 1% are fraud. A model labeling everything &#8220;legit&#8221; has 99% accuracy but is useless.<\/li>\n\n\n\n<li><strong>Fix:<\/strong> Use F1-Score or AUC instead.<\/li>\n\n\n\n<li><strong>Scenario 2: Asymmetric Error Costs<\/strong><\/li>\n\n\n\n<li><strong>Medical Diagnosis:<\/strong> Missing a cancer patient (False Negative) is deadly \u2192 Prioritize <strong>Recall<\/strong>.<\/li>\n\n\n\n<li><strong>Spam Detection:<\/strong> Flagging a crucial email as spam (False Positive) angers users \u2192 Prioritize <strong>Precision<\/strong>.<\/li>\n\n\n\n<li><strong>Scenario 3: Probabilistic Models<\/strong><\/li>\n\n\n\n<li>For models like logistic regression, <strong>Log Loss<\/strong> is ideal because it evaluates prediction confidence.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Conclusion: The Golden Rule<\/strong><\/h3>\n\n\n\n<p>There\u2019s no one-size-fits-all metric. It\u2019s like asking, &#8220;Is a knife better than scissors?&#8221; Depends if you\u2019re chopping veggies or cutting fabric! Align your metric with the <strong>problem\u2019s needs<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Building a cancer detector? Don\u2019t sacrifice Recall for Precision!<\/li>\n\n\n\n<li>Predicting house prices? Log Loss or RMSE might work better.<\/li>\n<\/ul>\n\n\n\n<p>.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: Why Should You Care About Evaluation Metrics? Imagine you and your friends start a band. Each of you plays a different instrument, but together, you create a flawless song&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":114,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61,62],"tags":[73,119,56,120,112,121,74,75,77,122,124],"class_list":["post-112","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-machine-learning","category-model-evaluation","tag-accuracy-2","tag-ensemble-learning","tag-f1-score","tag-log-loss","tag-model-evaluation","tag-practical-examples","tag-precision-2","tag-recall","tag-roc-auc","tag-seo","tag-social-media-2"],"_links":{"self":[{"href":"https:\/\/amirhooshang.com\/blog\/wp-json\/wp\/v2\/posts\/112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/amirhooshang.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/amirhooshang.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/amirhooshang.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/amirhooshang.com\/blog\/wp-json\/wp\/v2\/comments?post=112"}],"version-history":[{"count":2,"href":"https:\/\/amirhooshang.com\/blog\/wp-json\/wp\/v2\/posts\/112\/revisions"}],"predecessor-version":[{"id":115,"href":"https:\/\/amirhooshang.com\/blog\/wp-json\/wp\/v2\/posts\/112\/revisions\/115"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/amirhooshang.com\/blog\/wp-json\/wp\/v2\/media\/114"}],"wp:attachment":[{"href":"https:\/\/amirhooshang.com\/blog\/wp-json\/wp\/v2\/media?parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/amirhooshang.com\/blog\/wp-json\/wp\/v2\/categories?post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/amirhooshang.com\/blog\/wp-json\/wp\/v2\/tags?post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}