[{"data":1,"prerenderedAt":132},["ShallowReactive",2],{"term-c\u002Fconfusion-matrix":3,"related-c\u002Fconfusion-matrix":115},{"id":4,"title":5,"acronym":6,"body":7,"category":96,"description":97,"difficulty":98,"extension":99,"letter":100,"meta":101,"navigation":53,"path":102,"related":103,"seo":109,"sitemap":110,"stem":113,"subcategory":6,"__hash__":114},"terms\u002Fterms\u002Fc\u002Fconfusion-matrix.md","Confusion Matrix",null,{"type":8,"value":9,"toc":90},"minimark",[10,15,19,23,26,30,79,83,86],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 - The Vibe Check",[16,17,18],"p",{},"A confusion matrix is a little table that stops your model from lying to you with a single accuracy number. It breaks every prediction down into four buckets: correctly said yes, correctly said no, wrongly said yes, wrongly said no, so you can see exactly what kind of mistakes it's making, not just how often.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"A confusion matrix is a table that cross-tabulates a classification model's predicted labels against the actual labels, breaking results into true positives, true negatives, false positives, and false negatives. It's the raw material that precision, recall, and F1 score are calculated from, and it exposes lopsided error patterns that a single accuracy figure hides.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","from sklearn.metrics import confusion_matrix\n\ncm = confusion_matrix(y_true, y_pred)\n# [[TN, FP],\n#  [FN, TP]]\nprint(cm)\n","python","",[38,39,40,48,55,61,67,73],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,47],{},"from sklearn.metrics import confusion_matrix\n",[41,49,51],{"class":43,"line":50},2,[41,52,54],{"emptyLinePlaceholder":53},true,"\n",[41,56,58],{"class":43,"line":57},3,[41,59,60],{},"cm = confusion_matrix(y_true, y_pred)\n",[41,62,64],{"class":43,"line":63},4,[41,65,66],{},"# [[TN, FP],\n",[41,68,70],{"class":43,"line":69},5,[41,71,72],{},"#  [FN, TP]]\n",[41,74,76],{"class":43,"line":75},6,[41,77,78],{},"print(cm)\n",[11,80,82],{"id":81},"when-youll-hear-this","When You'll Hear This",[16,84,85],{},"\"The accuracy looked great until we checked the confusion matrix and saw it was calling everything 'not fraud'.\" \u002F \"Plot the confusion matrix so we can see which classes the model actually confuses.\"",[87,88,89],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":50,"depth":50,"links":91},[92,93,94,95],{"id":13,"depth":50,"text":14},{"id":21,"depth":50,"text":22},{"id":28,"depth":50,"text":29},{"id":81,"depth":50,"text":82},"ai","A confusion matrix is a little table that stops your model from lying to you with a single accuracy number.","beginner","md","c",{},"\u002Fterms\u002Fc\u002Fconfusion-matrix",[104,105,106,107,108],"Precision","Recall","F1 Score","Class Imbalance","Classification",{"title":5,"description":97},{"changefreq":111,"priority":112},"weekly",0.7,"terms\u002Fc\u002Fconfusion-matrix","RsuZXt8FxDudSgWsQ5lUPrFBv5am5qW_2FuN-ClMJyo",[116,120,123,126,129],{"title":107,"path":117,"acronym":6,"category":96,"difficulty":118,"description":119},"\u002Fterms\u002Fc\u002Fclass-imbalance","intermediate","Class imbalance is when your fraud detector trains on data where 99.9% of transactions are totally normal, so it can hit 99.",{"title":108,"path":121,"acronym":6,"category":96,"difficulty":98,"description":122},"\u002Fterms\u002Fc\u002Fclassification","Classification is teaching an AI to sort things into categories. Is this email spam or not? Is this image a cat, dog, or bird?",{"title":106,"path":124,"acronym":6,"category":96,"difficulty":118,"description":125},"\u002Fterms\u002Ff\u002Ff1-score","The F1 Score is the balanced average of precision and recall — a single number that captures both.",{"title":104,"path":127,"acronym":6,"category":96,"difficulty":118,"description":128},"\u002Fterms\u002Fp\u002Fprecision","Precision asks: 'Of all the times the AI said YES, how often was it actually right?",{"title":105,"path":130,"acronym":6,"category":96,"difficulty":118,"description":131},"\u002Fterms\u002Fr\u002Frecall","Recall asks: 'Of all the actual YES cases in the world, how many did the AI catch?' High recall means the model finds almost everything it should.",1792528073460]