Machine learning courses often throw a dozen algorithms at you in a week. It is more useful to know a few well: what kind of problem each solves, what it needs from the data, and where it breaks. Here are nine that cover most beginner and interview needs.
First: which kind of problem is it?
- Regression: predict a number (delivery time, price, demand).
- Classification: predict a category (will repay or default, spam or not).
- Clustering: find natural groups when there is no label (customer segments).
- Dimensionality reduction: squeeze many columns into a few meaningful ones.
The first two are supervised (you have historical answers to learn from). The last two are unsupervised (no answers, just structure).
1. Linear Regression
- What it does: fits a straight-line relationship between inputs and a number.
- Good for: predicting a food order's delivery time from distance, items and time of day.
- Watch out for: relationships that are not straight lines, and outliers that drag the line.
- Why learn it first: its coefficients are easy to explain ("each extra km adds about this many minutes"). Linear Regression lesson.
2. Logistic Regression
- What it does: despite the name, a classifier. It outputs a probability between 0 and 1.
- Good for: estimating the chance a loan applicant defaults, then choosing a cut-off.
- Watch out for: it assumes a fairly simple boundary between classes; scale your features.
- Why it matters: still widely used where decisions must be explained. Logistic Regression lesson.
3. K-Nearest Neighbours (KNN)
- What it does: looks at the K most similar past examples and copies their answer.
- Good for: recommending a plan based on what similar customers chose.
- Watch out for: you must scale features (otherwise "income in rupees" swamps "age in years"), and it gets slow with lots of data. KNN lesson.
4. Decision Tree
- What it does: learns a flowchart of yes/no questions.
- Good for: finding which employees are likely to leave, with rules HR can read.
- Watch out for: a deep tree memorises the training data (overfitting). Limit its depth. Decision Tree lesson.
5. Random Forest
- What it does: trains many trees on random slices of data and lets them vote.
- Good for: predicting which telecom customers will stop recharging.
- Watch out for: less explainable than a single tree; use feature importance to see what drives it. Random Forest lesson.
6. Naive Bayes
- What it does: uses word (or feature) probabilities, assuming features are independent.
- Good for: text: spam detection, routing support tickets by their words.
- Watch out for: the "naive" independence assumption is rarely true, yet it often works surprisingly well for text. Naive Bayes lesson.
7. Support Vector Machine (SVM)
- What it does: finds the boundary with the widest margin between classes; kernels let it draw curved boundaries.
- Good for: flagging risky transactions when classes are not separable by a straight line.
- Watch out for: needs scaled features and careful tuning; slow on very large datasets. SVM lesson.
8. K-Means Clustering
- What it does: splits data into K groups so points in a group are close to their group's centre.
- Good for: grouping shoppers for targeted offers.
- Watch out for: you choose K (use the elbow method or silhouette score), and it assumes roughly round, similar-sized groups. K-Means lesson.
9. PCA
- What it does: combines many correlated columns into a few "components" that keep most of the information.
- Good for: shrinking a long survey into two or three clear scores, or simplifying data before another model.
- Watch out for: components are combinations of columns, so you must interpret them. PCA lesson.
How to choose in practice
- Start simple: linear regression for numbers, logistic regression for yes/no. They give you a baseline and they are explainable.
- If the simple model is not good enough and explanation is less important, try a random forest.
- For text, try Naive Bayes first.
- For no labels, K-Means for groups, PCA for simplification.
- Always compare models on data they have not seen, using the right metric.
Learn by seeing and doing
Every algorithm above has a worked example, a visual playground where you drag points and change settings to see the model react, and practice questions you solve in Python. Start from the ML section of the practice page. If you are still choosing between the first two, read linear vs logistic regression.
Practise what you just read
Reading helps; writing the code yourself is what sticks. Start here: