Classification predicts a category — a choice among options. Will this customer pay or default? Is this transaction fraud or legitimate? Which category does this expense belong to?
Where regression predicts numbers ("how much?"), classification predicts labels ("which one?"). In finance, many of the most important decisions are classification problems: approve/decline, fraud/not fraud, high risk / low risk.
Logistic regression predicts a probability between 0 and 1. It's the workhorse of binary classification in finance — especially for credit scoring.
Each feature contributes to the probability. If the probability crosses a threshold (say 50%), you predict "yes." The model is interpretable: each feature's coefficient tells you how it shifts the odds of default.
It's still widely used today because regulators love it — you can explain every prediction in plain language.
A decision tree asks a series of yes/no questions, narrowing down to a final prediction:
"Is income > $50,000?" → "Yes" → "Is debt < $10,000?" → "Yes" → "Approve loan."
You can literally read the tree and understand it. That's why regulators, doctors, and business teams love it. But trees alone overfit easily — they memorize the training data. That's why we also learn about forests later.
Naive Bayes uses probabilities of each feature given each class, then applies Bayes' rule to predict. It's simple, fast, and surprisingly strong for text — e.g., classifying expense descriptions ("AMZN" → "Office Supplies").
K‑nearest neighbors (KNN) predicts by looking at the K closest training examples in feature space. If your neighbors mostly defaulted, you probably will too. Very intuitive — and great for detecting unusual patterns.
Most financial classification problems are imbalanced: only 2% of loans default, only 0.1% of transactions are fraud. A naive model can say "no one defaults" and still be 98% accurate — but useless.
Fixes: class weighting (tell the model to care more about the rare class), oversampling (duplicate or synthesize minority examples), undersampling (drop some majority examples), and threshold tuning (predict the rare class more easily).
The confusion matrix shows every prediction against reality:
Precision = of the ones we flagged, how many were real? Recall = of the real ones, how many did we catch? F1 balances both. In finance, the right balance depends on the cost of false alarms vs. missed fraud.
The ROC curve plots true positive rate vs. false positive rate at every possible threshold. A model with a strong curve sits close to the top‑left corner — catching most positives without too many false alarms.
AUC (Area Under the Curve) summarizes the whole curve in one number. 0.5 = random guessing. 1.0 = perfect model. In credit scoring and fraud detection, AUC is one of the most‑cited metrics — and easy to compare across models.
Binary thinking: List three financial decisions that are classification problems and three that are regression problems. Explain each in one sentence.
Tree rules: Write a small decision tree by hand for a "should I lend money?" scenario. Use 3–4 yes/no questions. Test it on three imaginary applicants and see who gets approved.
Imbalance math: In a fraud dataset, 995 transactions are legitimate, 5 are fraud. What's the accuracy of "always say not fraud"? What's the recall? Explain why this "high‑accuracy" model is useless.
Confusion matrix reading: Given a 2x2 confusion matrix with TP=8, FP=4, FN=2, TN=86, compute precision and recall by hand. Then compare: which is more important for fraud detection — precision or recall?
Alarm tradeoff: Set a low threshold — you catch every fraud but get lots of false alarms. Set a high threshold — you catch few frauds but few false alarms. Describe the real‑world tradeoff in 2 sentences. Which matters most for a card issuer?
Model selector: For each scenario, pick logistic regression, decision tree, or KNN and justify: (a) you need to explain every rejection to a customer; (b) you're classifying short transaction descriptions; (c) you're detecting unusual vendor patterns.
By the end of this module, you'll be able to: build classifiers with logistic regression, trees, Naive Bayes, and KNN, handle class imbalance, read confusion matrices, compute precision and recall, and interpret ROC/AUC like a finance pro.