Can a 99% accurate model be useless?
A machine that catches fraud. Ninety nine percent correct. And it has never caught a single fraud. Its whole trick: telling every payment 'not fraud'. So how can a machine be ninety nine percent right and still useless? Take a made-up month: ten thousand payments, a hundred of them fraud. Right nine thousand nine hundred times, useless every time.
हिन्दी में पढ़ें
फ़्रॉड पकड़ने वाली एक मशीन। निन्यानवे परसेंट सही। और उसने आज तक एक भी फ़्रॉड नहीं पकड़ा। उसकी पूरी तरकीब: हर पेमेंट को बोल देना, फ़्रॉड नहीं। तो कोई मशीन निन्यानवे परसेंट सही होकर भी बेकार कैसे हो सकती है? एक बनाया हुआ महीना लीजिए। दस हज़ार पेमेंट, उनमें सौ फ़्रॉड। मशीन नौ हज़ार नौ सौ बार सही, और हर बार बेकार।
What you will be able to answer
I am BSK. I build products with AI. The source of every claim is on screen. By the end, you will say yourself how so high a number can be useless. At the end there is a medical test question most doctors in one study got wrong. Know this topic already? Try it too.
हिन्दी में पढ़ें
मैं बी एस के। ए आई से प्रोडक्ट बनाता हूँ। हर दावे का सोर्स स्क्रीन पे दिखेगा। आख़िर तक आप ख़ुद बता पाएँगे कि इतना ऊँचा नंबर भी बेकार कैसे हो सकता है। आख़िर में एक मेडिकल टेस्ट का सवाल है, जिसपे एक स्टडी में ज़्यादातर डॉक्टर चूक गए। ये विषय पहले से जानते हैं, तो भी उसे आज़माइए।
Three parts. How this number fools you. Which two do not. And who chooses the mistake to live with.
हिन्दी में पढ़ें
तीन हिस्से हैं। ये नंबर धोखा कैसे देता है। कौन से दो नंबर नहीं देते। और कौन सी ग़लती झेलनी है, ये कौन चुनता है।
What you need first: score and threshold
Two things first. One: a machine that learned from data, a model, gives each case a score. Then a person draws a line on it, called the threshold. Two: a model is tested on cases it did not see while learning. This channel's AI course covers both. Which number to judge it by is today's subject.
हिन्दी में पढ़ें
पहले दो बातें। पहली: डेटा से सीखी मशीन, यानी मॉडल, हर मामले को एक स्कोर देता है। फिर कोई इंसान उसपे एक लकीर खींचता है। इस लकीर को थ्रेशोल्ड कहते हैं। दूसरी: मॉडल को उन मामलों पे जाँचते हैं, जो उसने सीखते वक़्त नहीं देखे। इस चैनल के ए आई कोर्स में दोनों पर एपिसोड हैं। पर जाँच किस नंबर से हो, ये आज की बात है।
What accuracy means
The machine's ninety nine percent counts one thing: of all the answers it gave, how many were right. This is called accuracy. Many people believe this: accuracy tells you how good a model is. The higher the number, the better the model. It sounds perfectly fair. But our machine is useless, and this number hid it.
हिन्दी में पढ़ें
हमारी मशीन का निन्यानवे परसेंट एक ही बात गिनता है: उसने जितने जवाब दिए, उनमें से कितने सही निकले। इसे एक्युरेसी कहते हैं। बहुत लोग मानते हैं: एक्युरेसी बता देती है कि मॉडल कितना अच्छा है। जितना ऊँचा नंबर, उतना अच्छा मॉडल। सुनने में बिल्कुल ठीक लगता है। पर हमारी मशीन बेकार है, और इस नंबर ने ये छिपा लिया।
So why was the ninety nine percent machine useless? The answer is in the one thing it never said.
हिन्दी में पढ़ें
तो निन्यानवे परसेंट वाली मशीन बेकार क्यों थी? जवाब उस एक बात में है, जो वो कभी नहीं बोली।
Accuracy on imbalanced data
Accuracy counts every answer the same. Catching a fraud and calling a normal payment normal earn exactly the same point. When ninety nine payments in a hundred are normal, saying 'not fraud' every time is right ninety nine times. Without learning a thing. Now put this machine in a month where half the payments are fraud. Accuracy: fifty percent.
हिन्दी में पढ़ें
एक्युरेसी हर जवाब को बराबर गिनती है। एक फ़्रॉड पकड़ना, और एक आम पेमेंट को आम कहना, दोनों का एक ही नंबर। जब सौ में से निन्यानवे पेमेंट आम हों, तो हर बार फ़्रॉड नहीं कहना, अपने आप निन्यानवे बार सही होगा। बिना कुछ सीखे। अब इसी मशीन को ऐसे महीने में रखिए, जहाँ आधे पेमेंट फ़्रॉड हों। एक्युरेसी सीधी पचास परसेंट।
Ninety nine or fifty. Same machine, just as lazy. Only the data differs. So when the thing you look for is rare, accuracy hides everything. And the rare thing is often the one that matters most. Lots of examples of one kind, very few of the other. This is called class imbalance.
हिन्दी में पढ़ें
निन्यानवे या पचास। मशीन वही है, उतनी ही आलसी। फ़र्क़ सिर्फ़ डेटा का है। तो जब ढूँढी जाने वाली चीज़ बहुत कम हो, एक्युरेसी सब कुछ छिपा लेती है। और जो कम होता है, अक्सर वही सबसे ज़रूरी होता है। एक तरह के उदाहरण बहुत ज़्यादा, और दूसरी तरह के बहुत कम। इसे क्लास इम्बैलेंस कहते हैं।
Now real data. A public dataset of payments by European cardholders, two days. About two hundred eighty five thousand payments, only four hundred ninety two frauds. Here a machine that always says 'not fraud' would be ninety nine point eight percent right. Not a classroom trick. The real world. And if frauds are too few to learn from? Then it learns what a normal payment looks like, and flags the odd. This is anomaly detection.
हिन्दी में पढ़ें
अब असली डेटा। यूरोप के कार्ड वालों के पेमेंट का एक पब्लिक डेटासेट, दो दिन का। लगभग दो लाख पचासी हज़ार पेमेंट, और फ़्रॉड सिर्फ़ चार सौ बानवे। यहाँ हर बार फ़्रॉड नहीं कहने वाली मशीन, निन्यानवे दशमलव आठ परसेंट सही होगी। ये क्लास का खेल नहीं, असली दुनिया है। और फ़्रॉड इतने कम हों कि मशीन उनसे सीख ही न पाए? तब वो सीखती है कि आम पेमेंट कैसा दिखता है, और अजीब पे झंडा लगाती है। इसे एनॉमली डिटेक्शन कहते हैं।
So the first question for any accuracy: what would a blind guess that always gives one answer get? Weigh every accuracy against the score of always giving the commonest answer. Here the bar is ninety nine, not fifty.
हिन्दी में पढ़ें
इसलिए किसी भी एक्युरेसी पे पहला सवाल: आँख बंद करके हर बार एक ही जवाब देने वाला कितना पाता? हर एक्युरेसी को, सबसे आम जवाब देने वाले के नंबर से तौलिए। यहाँ मुक़ाबला पचास से नहीं, निन्यानवे से है।
False positive and false negative
So stop counting the right answers. Count the wrong ones. Because there are two kinds of mistake. Mistake one: a false alarm. The payment was fine, and the machine called it fraud. Mistake two: a miss. It was fraud, and it got through.
हिन्दी में पढ़ें
तो सही जवाब गिनना छोड़िए। ग़लत जवाब गिनिए। क्योंकि ग़लती भी दो तरह की होती है। पहली ग़लती: झूठा अलार्म। पेमेंट बिल्कुल ठीक था, और मशीन ने उसे फ़्रॉड बता दिया। दूसरी ग़लती: चूक। फ़्रॉड था, और मशीन ने उसे जाने दिया।
What we are hunting, here fraud, is called positive. So a false alarm is a false positive. And a miss is a false negative. Right and wrong together make four boxes. Fraud caught. Fraud missed. False alarm. And a good payment, rightly left alone. This two by two table is the confusion matrix. Every number in this episode is built from its four counts.
हिन्दी में पढ़ें
जिस चीज़ को हम ढूँढ रहे हैं, यहाँ फ़्रॉड, उसे पॉज़िटिव कहते हैं। तो झूठा अलार्म है फ़ॉल्स पॉज़िटिव। और चूक है फ़ॉल्स नेगेटिव। सही और ग़लत मिलाकर चार ख़ाने बनते हैं। पकड़ा गया फ़्रॉड। छूटा हुआ फ़्रॉड। झूठा अलार्म। और ठीक पेमेंट, जिसे ठीक छोड़ा। इस दो बाय दो टेबल को कन्फ़्यूज़न मैट्रिक्स कहते हैं। इस एपिसोड के सारे नंबर, इन्हीं चार गिनतियों से बनते हैं।
For now, assume we know which payments really were fraud. In real life a miss comes to light later, and some never do. Now put the lazy machine in the boxes. Not one false alarm. And misses: all hundred. Now a machine that really learned something. Two parts. A dial from zero to a hundred, where it scores every payment. And a red line somebody drew: the threshold.
हिन्दी में पढ़ें
अभी के लिए मान लीजिए कि हमें पता है, कौन सा पेमेंट सच में फ़्रॉड था। असल ज़िंदगी में चूक का पता बाद में चलता है, और कुछ का कभी नहीं। अब आलसी मशीन को इन ख़ानों में रखिए। झूठा अलार्म एक भी नहीं। और चूक, पूरी सौ। अब एक मशीन, जिसने सच में कुछ सीखा है। उसके दो हिस्से हैं। शून्य से सौ का एक डायल, जिसपे वो हर पेमेंट को स्कोर देती है। और एक लाल लकीर, जो किसी ने खींची है: यही थ्रेशोल्ड।
The red line is at fifty. Your guess: will this hard-working machine's accuracy be above the lazy one's ninety nine, or below? Below. Ninety five percent. The machine that does nothing is ahead on the number. But it caught ninety five of the hundred frauds. The lazy machine caught none.
हिन्दी में पढ़ें
लाल लकीर पचास पे है। आपका अंदाज़ा: इस मेहनती मशीन की एक्युरेसी, आलसी मशीन के निन्यानवे से ऊपर होगी, या नीचे? नीचे। पंचानवे परसेंट। जो मशीन कुछ नहीं करती, वो नंबर में आगे है। पर इसने सौ में से पंचानवे फ़्रॉड पकड़ लिए। आलसी मशीन ने एक भी नहीं।
And the price? Four hundred sixty six false alarms: good payments stopped. Accuracy could not show the real difference between these machines. It even put the useless one ahead. Two other numbers do that job.
हिन्दी में पढ़ें
और क़ीमत? चार सौ छियासठ झूठे अलार्म। यानी इतने ठीक पेमेंट बेवजह रुके। एक्युरेसी इन दोनों मशीनों का असली फ़र्क़ नहीं दिखा पाई। उल्टा, उसने बेकार वाली को आगे रखा। ये काम दो दूसरे नंबर करते हैं।
Precision and recall explained
Picture the payments the machine stopped as a fishing net's haul. A fish is a fraud. Rubbish is a good payment stopped. The pond is every payment. Whoever casts it asks first: in the haul, how much is fish, how much rubbish?
हिन्दी में पढ़ें
मशीन ने जो पेमेंट रोके, उन्हें मछली के जाल की तरह देखिए। मछली है फ़्रॉड। कचरा है वो ठीक पेमेंट, जो बेवजह रुका। और तालाब है सारे पेमेंट। जाल डालने वाला पहले पूछता है: जो जाल में आया, उसमें मछली कितनी, और कचरा कितना?
For the machine it is the same question: of the payments it called fraud, how many really were. This is called precision. Then: of all the fish in the pond, how many did the net catch? For the machine: of all the real frauds, how many were caught. This is called recall.
हिन्दी में पढ़ें
मशीन के लिए यही सवाल है: जिन पेमेंट को उसने फ़्रॉड कहा, उनमें से कितने सच में फ़्रॉड थे। इसे प्रिसिज़न कहते हैं। फिर वो पूछता है: तालाब की सारी मछलियों में से, जाल ने कितनी पकड़ीं? मशीन के लिए: जितने असली फ़्रॉड थे, उनमें से कितने पकड़े गए। इसे रिकॉल कहते हैं।
One place the picture fails. To change a net's mesh you need a new net. With the machine, you just move the red line. With the red line at fifty, recall is ninety five percent: ninety five of a hundred caught. But precision is only seventeen percent. It stopped about five hundred fifty payments, and ninety five were fraud.
हिन्दी में पढ़ें
बस एक जगह ये तस्वीर नहीं चलती। जाल के छेद बदलने हों, तो नया जाल चाहिए। मशीन में बस लाल लकीर खिसकानी है। लाल लकीर पचास पे हो, तो रिकॉल पंचानवे परसेंट। सौ में से पंचानवे फ़्रॉड पकड़े गए। पर प्रिसिज़न सिर्फ़ सत्रह परसेंट। मशीन ने लगभग साढ़े पाँच सौ पेमेंट रोके, और फ़्रॉड उनमें पंचानवे थे।
So in this machine, what is the rubbish? Good payments stopped for nothing. Someone's rent, someone's medicine. Now a question for you. The lazy machine told every payment 'not fraud'. What is its recall? Zero. Not one fish. So ends its ninety nine percent magic.
हिन्दी में पढ़ें
तो इस मशीन में कचरा क्या है? वही ठीक पेमेंट, जो बेवजह रुके। किसी का किराया, किसी की दवा। अब एक सवाल आपसे। आलसी मशीन ने हर पेमेंट को फ़्रॉड नहीं कहा था। उसका रिकॉल कितना होगा? शून्य। उसने एक भी मछली नहीं पकड़ी। निन्यानवे परसेंट का सारा जादू यहीं ख़त्म।
Next time someone impresses you with an AI's big number, ask: what did it miss?
हिन्दी में पढ़ें
अगली बार कोई ए आई का बड़ा सा नंबर दिखाकर इम्प्रेस करे, तो पूछिए: इसने छोड़ा क्या?
Precision vs recall trade-off and F1
The obvious fix? Find a line that catches every fraud and raises no false alarm. But there is a problem. Move the red line up, to sixty. Now the machine stops only the more suspicious payments. False alarms fall from four hundred sixty six to forty seven. Far less rubbish. But now thirty frauds slip through: fish escape.
हिन्दी में पढ़ें
तो सीधा उपाय? ऐसी लकीर ढूँढिए जो हर फ़्रॉड पकड़े, और एक भी झूठा अलार्म न दे। लेकिन एक दिक़्क़त है। लाल लकीर को थोड़ा ऊपर, साठ पे ले चलिए। अब मशीन सिर्फ़ ज़्यादा शक वाले पेमेंट रोकेगी। झूठे अलार्म चार सौ छियासठ से गिरकर सैंतालीस रह गए। कचरा बहुत कम। पर अब तीस फ़्रॉड छूट गए: मछलियाँ निकल गईं।
Less rubbish, so precision climbs to about sixty percent. Fish escaped, so recall falls to seventy. Higher, to seventy. Only two false alarms. But now more than half the frauds, fifty nine, got away. Precision ninety five: almost only fish in the net. But recall forty one: most fish stayed behind.
हिन्दी में पढ़ें
कचरा कम हुआ, तो प्रिसिज़न चढ़कर लगभग साठ परसेंट। मछलियाँ छूटीं, तो रिकॉल गिरकर सत्तर। और ऊपर, सत्तर पे। झूठे अलार्म सिर्फ़ दो। पर अब आधे से ज़्यादा फ़्रॉड, उनसठ, निकल गए। प्रिसिज़न पंचानवे, यानी जाल में लगभग सिर्फ़ मछली। पर रिकॉल इकतालीस: ज़्यादातर मछलियाँ तालाब में रह गईं।
That is the net again. A fine mesh catches every fish, and a lot of rubbish. A wide mesh is the reverse: little rubbish, but fish escape. A low red line: fine mesh. A high one: wide mesh. Unless the machine itself gets better, moving the line usually trades one for the other. Both do not rise together.
हिन्दी में पढ़ें
यही जाल की बात है। बारीक जाल हर मछली पकड़ता है, और साथ में ढेर सारा कचरा। चौड़े छेद वाला जाल उल्टा: कचरा कम, पर मछलियाँ भी निकल जाती हैं। नीची लाल लकीर बारीक जाल है। ऊँची लाल लकीर, चौड़ा जाल। जब तक मशीन ख़ुद बेहतर न बने, लकीर खिसकाकर आप अक्सर एक को दूसरे से बदलते हैं। दोनों एक साथ ऊपर नहीं जाते।
Each line is one point on this machine's precision-recall curve. The line moves you along it. Only a better machine lifts the curve. The two also combine into one number, F1. It is high only when both are high. If one is low, F1 stays close to it. Of our three lines, F1 is highest at sixty. But even the highest F1 does not say where the line should go.
हिन्दी में पढ़ें
हर लकीर, इसी मशीन के प्रिसिज़न रिकॉल कर्व का एक बिंदु है। लकीर से आप कर्व पे चलते हैं। कर्व को ऊपर, सिर्फ़ बेहतर मशीन उठाती है। दोनों को मिलाकर एक नंबर भी बनता है, एफ़ वन। ये तभी ऊँचा आता है, जब दोनों ऊँचे हों। एक भी बहुत नीचे हो, तो ये उसी के पास रहता है। हमारी तीन लकीरों में, एफ़ वन साठ पे सबसे ऊँचा है। पर सबसे ऊँचा एफ़ वन भी नहीं बताता कि लकीर कहाँ हो।
And accuracy? More frauds got away, yet it climbed from ninety five to past ninety nine. False alarms fell far faster, and to accuracy every mistake weighs the same. So who decides where the line goes? And on what basis?
हिन्दी में पढ़ें
और एक्युरेसी? फ़्रॉड ज़्यादा छूटे, फिर भी वो पंचानवे से निन्यानवे के पार चली गई। क्योंकि झूठे अलार्म उससे कहीं ज़्यादा घटे, और एक्युरेसी की नज़र में हर ग़लती बराबर है। तो लकीर कहाँ खिंचे, ये तय कौन करे? और किस आधार पे?
How to choose the threshold
There is no line that is right in itself. The biggest question is which mistake costs more. A false alarm: you are at the shop counter, a long queue behind you, and your payment is blocked. A miss: somebody else took your money, and the machine said nothing.
हिन्दी में पढ़ें
अपने आप में सही लकीर जैसी कोई चीज़ नहीं होती। सबसे बड़ा सवाल ये है कि किस ग़लती की क़ीमत ज़्यादा है। झूठा अलार्म यानी आप दुकान के काउंटर पे खड़े हैं, पीछे लंबी लाइन है, और आपका पेमेंट रुक गया। चूक यानी किसी और ने आपके पैसे निकाल लिए, और मशीन चुप रही।
One is a nuisance, the other a loss. So a low line makes sense, and when in doubt, ask: did you make this payment? A spam filter is the reverse. There the alarm means sending a mail to spam. A junk mail getting in is fine. A job offer lost in spam is a real loss. So there a high line makes sense. Maths alone does not decide where the line goes. People put a price on each mistake, and that price sets the line.
हिन्दी में पढ़ें
एक में परेशानी है, दूसरे में नुक़सान। ऐसे में लकीर नीचे रखना समझ में आता है, और शक हो तो पूछ लीजिए: ये पेमेंट आपने किया? स्पैम फ़िल्टर में उल्टा है। वहाँ अलार्म का मतलब है, मेल को स्पैम में डालना। फ़ालतू मेल अंदर आ गई, तो चलेगा। पर नौकरी का ऑफ़र स्पैम में गया, तो बड़ा नुक़सान। इसलिए वहाँ ऊँची लकीर समझ में आती है। लकीर कहाँ हो, ये गणित अकेले तय नहीं करता। हर ग़लती की क़ीमत इंसान तय करते हैं, और उसी से लकीर तय होती है।
Why a 95% accurate test can mislead
Now the medical test question I promised at the start. Suppose a test is called ninety five percent accurate, and one person in a hundred has the disease. These numbers are ours, chosen to explain. Your test comes back positive. What are the chances you are really sick? Many would say ninety five percent straight away.
हिन्दी में पढ़ें
अब वो मेडिकल टेस्ट वाला सवाल, जिसका वादा शुरू में किया था। मान लीजिए एक टेस्ट है, जिसे पंचानवे परसेंट सही कहा जाता है। और बीमारी सौ में से एक इंसान को है। ये नंबर हमने समझाने के लिए चुने हैं। आपका टेस्ट पॉज़िटिव आया। आप सच में बीमार हों, इसके चांस कितने हैं? बहुत से लोग झट से कहेंगे, पंचानवे परसेंट।
Take ten thousand people. A hundred sick, nine thousand nine hundred healthy. The test catches ninety five of the hundred sick. Good. But it also calls five percent of the healthy positive. That is four hundred ninety five people.
हिन्दी में पढ़ें
दस हज़ार लोग लीजिए। सौ बीमार, नौ हज़ार नौ सौ ठीक। टेस्ट सौ बीमारों में से पंचानवे को पकड़ लेता है। बढ़िया। पर ठीक लोगों में से भी पाँच परसेंट को पॉज़िटिव बता देता है। यानी चार सौ पंचानवे लोग।
Five hundred ninety positives in all. Only ninety five are sick. About sixteen percent. Said plainly: a test ninety five percent accurate can be wrong most of the times it says positive. The rarer the disease, the more often. This is the test's precision. The net brought up mostly rubbish, because the pond had few fish.
हिन्दी में पढ़ें
कुल पाँच सौ नब्बे पॉज़िटिव। उनमें बीमार सिर्फ़ पंचानवे। यानी लगभग सोलह परसेंट। सीधी बात ये है: पंचानवे परसेंट सही टेस्ट भी, जब पॉज़िटिव कहता है, तो ज़्यादातर बार ग़लत हो सकता है। बीमारी जितनी कम, ग़लती उतनी ज़्यादा। ये उसी टेस्ट का प्रिसिज़न है। जाल में ज़्यादातर कचरा आया, क्योंकि तालाब में मछलियाँ ही कम थीं।
This is education only, not medical advice. Ask your doctor what your report means. So would doctors do better? A study published in twenty fourteen asked sixty one doctors, trainee doctors and medical students at a hospital near Boston a question like this. There the disease hit one in a thousand, with five percent false alarms. The right answer: about two percent.
हिन्दी में पढ़ें
ये सिर्फ़ जानकारी है, डॉक्टरी सलाह नहीं। आपकी रिपोर्ट का मतलब, अपने डॉक्टर से पूछिए। तो क्या डॉक्टर इसमें बेहतर निकलेंगे? दो हज़ार चौदह में एक स्टडी छपी। उसमें बोस्टन इलाक़े के एक अस्पताल के इकसठ डॉक्टरों, ट्रेनी डॉक्टरों और मेडिकल छात्रों से ऐसा ही सवाल पूछा गया था। वहाँ बीमारी हज़ार में एक को थी, और झूठे अलार्म पाँच परसेंट। सही जवाब था लगभग दो परसेंट।
The most common answer was ninety five percent. Only fourteen of the sixty one got it right. The number fooled them too.
हिन्दी में पढ़ें
सबसे ज़्यादा लोगों का जवाब था पंचानवे परसेंट। सही जवाब इकसठ में से सिर्फ़ चौदह ने दिया। नंबर ने उन्हें भी धोखा दिया।
How a 99% accurate model can be useless
So, the ninety nine percent machine. Fraud was one in a hundred, so 'not fraud' was right ninety nine times. But it caught not one fraud. So how can a machine be ninety nine percent right and still useless? When the thing you hunt is rare, accuracy hides the misses. So count not the number but both mistakes: false alarms, and misses.
हिन्दी में पढ़ें
तो वो निन्यानवे परसेंट वाली मशीन। फ़्रॉड सौ में एक था, इसलिए फ़्रॉड नहीं कहना निन्यानवे बार सही था। पर उसने एक भी फ़्रॉड नहीं पकड़ा। तो कोई मशीन निन्यानवे परसेंट सही होकर भी बेकार कैसे हो सकती है? जब ढूँढी जाने वाली चीज़ कम हो, एक्युरेसी चूक को छिपा लेती है। इसलिए नंबर नहीं, दोनों ग़लतियाँ गिनिए: झूठे अलार्म, और चूक।
For your bank, which mistake is worse, a false alarm or a miss? Tell me in the comments. Which models actually run banks? That is the next episode. Subscribe.
हिन्दी में पढ़ें
आपके बैंक के लिए कौन सी ग़लती ज़्यादा बुरी है, झूठा अलार्म या चूक? कमेंट में बताइए। बैंक असल में कौन से मॉडल चलाते हैं? अगला एपिसोड यही है। सब्सक्राइब कीजिए।
Ideas to keep
- Class imbalance
- Lots of examples of one kind, very few of the other. This is called class imbalance.
- Precision
- For the machine it is the same question: of the payments it called fraud, how many really were. This is called precision.
- Recall
- For the machine: of all the real frauds, how many were caught. This is called recall.
THE WORKED CASE
Follow the example
Take a made-up month: ten thousand payments, a hundred of them fraud. Right nine thousand nine hundred times, useless every time. Accuracy counts every answer the same. Catching a fraud and calling a normal payment normal earn exactly the same point. When ninety nine payments in a hundred are normal, saying 'not fraud' every time is right ninety nine times. Without learning a thing. Now put this machine in a month where half the payments are fraud. Accuracy: fifty percent. Ninety nine or fifty. Same machine, just as lazy. Only the data differs. So when the thing you look for is rare, accuracy hides everything. And the rare thing is often the one that matters most. Lots of examples of one kind, very few of the other. This is called class imbalance. Picture the payments the machine stopped as a fishing net's haul. A fish is a fraud. Rubbish is a good payment stopped. The pond is every payment. Whoever casts it asks first: in the haul, how much is fish, how much rubbish? For the machine it is the same question: of the payments it called fraud, how many really were. This is called precision. Then: of all the fish in the pond, how many did the net catch? For the machine: of all the real frauds, how many were caught. This is called recall. One place the picture fails. To change a net's mesh you need a new net. With the machine, you just move the red line. With the red line at fifty, recall is ninety five percent: ninety five of a hundred caught. But precision is only seventeen percent. It stopped about five hundred fifty payments, and ninety five were fraud. So in this machine, what is the rubbish? Good payments stopped for nothing. Someone's rent, someone's medicine. Now a question for you. The lazy machine told every payment 'not fraud'. What is its recall? Zero. Not one fish. So ends its ninety nine percent magic.
Check your understanding
Go to the source
- Machine Learning Crash Course (Google for Developers), "Classification: Accuracy, recall, precision, and related metrics"
- Machine Learning Crash Course, "Thresholds and the confusion matrix"
- The dataset's description (Worldline and the ULB Machine Learning Group; Dal Pozzolo, Caelen, Johnson, Bontempi, IEEE CIDM 2015), on OpenML
- Manrai, Bhatia, Strymish, Kohane, Jain, JAMA Internal Medicine 174(6), 2014