Logistic Regression and K-Nearest Neighbors
The one idea: Logistic regression draws one smooth boundary through your data and hands you a probability plus a coefficient you can explain in a sentence ("each extra late payment roughly doubles default odds"). KNN draws no boundary at all — it just asks "what happened to the points that look like this one?" Reach for logistic regression when you need to explain why; reach for KNN when the pattern is too lumpy for any one line to capture and you're willing to trade explainability for flexibility.
⚠️ The trap: A logistic regression coefficient of 0.69 does not mean "a one-unit increase in this feature raises the probability of the outcome by 69%." Coefficients live on the log-odds scale, not the probability scale. You have to exponentiate first — e^0.69 ≈ 2.0 — and even then it means the odds double, not the probability. Odds of 50% (1:1) doubling to odds of 67% is a jump of 17 points; odds of 5% doubling to 10% is a jump of only 5 points. The size of the probability swing depends on where you started.
Both of these are workhorse binary classifiers — predicting one of two labels (churn/stay, default/repay, click/no-click) from a set of features. They solve the problem in almost opposite ways, and a course on classification should start here because most other classifiers are variations on one of these two ideas: fit a function (logistic regression, SVM, decision trees) versus look at your neighbors (KNN).
Logistic regression: fitting an S-curve, not a line
Linear regression predicts a number that can run off to ±∞. That's a problem for classification —…
Keep reading: Logistic Regression and Knn
Unlock the full Machine Learning track — every lesson, the AI tutor, and full mock assessments.
- Full lesson content
- AI tutor for this section
- Practice questions