Quick answer: For placement revision, machine learning fundamentals come down to six things: the main supervised and unsupervised algorithms and when to use each, evaluation metrics and their formulas, the bias-variance trade-off, how to fix overfitting, the train-validation-test split, and a standard scikit-learn workflow. This cheat sheet puts all six on one page.
This machine learning fundamentals cheat sheet is for the night before an interview or an online assessment. It assumes you have already learned the topics and need fast, accurate recall. Everything is in tables, so you can cover one column and test yourself.
If any row feels unfamiliar, do not memorise it. Go back and learn it properly with our machine learning engineer roadmap, because interviewers always ask "why?" after "what?".
Core ML vocabulary
| Term | Meaning in one line |
|---|---|
| Feature (X) | An input column the model learns from |
| Label / target (y) | The value you want to predict |
| Supervised learning | Learning from labelled examples (regression, classification) |
| Unsupervised learning | Finding structure without labels (clustering, PCA) |
| Regression | Predicting a number |
| Classification | Predicting a category |
| Parameter | Learned from data (e.g. regression weights) |
| Hyperparameter | Set by you before training (e.g. max_depth, k) |
| Baseline | The simplest reasonable model you must beat |
| Data leakage | Information from validation/test data sneaking into training |
Algorithms at a glance
| Algorithm | Type | Use when | Watch out for |
|---|---|---|---|
| Linear regression | Regression | Relationship is roughly linear | Outliers, correlated features |
| Ridge / Lasso | Regression | Many features, overfitting | Lasso can zero out features (feature selection) |
| Logistic regression | Classification | Fast, interpretable baseline | Needs scaling; linear decision boundary |
| K-nearest neighbours | Both | Small data, simple patterns | Slow at prediction; must scale features |
| Decision tree | Both | Need interpretability | Overfits easily without depth limits |
| Random forest | Both | Strong default for tabular data | Less interpretable; larger models |
| Gradient boosting | Both | Top accuracy on tabular data | Needs tuning; can overfit |
| SVM | Both | Medium data, clear margins | Slow on large data; needs scaling |
| Naive Bayes | Classification | Text, spam filtering, fast baseline | Assumes features are independent |
| K-Means | Clustering | Round, similar-size clusters | Choose k (elbow/silhouette); needs scaling |
| DBSCAN | Clustering | Odd-shaped clusters, noise | Sensitive to eps and min_samples |
| PCA | Dimensionality reduction | Too many correlated features | Components are hard to interpret |
Interview note: "Why random forest over a single decision tree?" Answer: averaging many trees trained on different samples and feature subsets reduces variance, so it overfits less.
Classification metrics and formulas
Confusion matrix terms: TP true positive, TN true negative, FP false positive (false alarm), FN false negative (missed case).
| Metric | Formula | Use when |
|---|---|---|
| Accuracy | (TP + TN) / (TP + TN + FP + FN) | Classes are balanced |
| Precision | TP / (TP + FP) | False alarms are costly (spam filter) |
| Recall (sensitivity) | TP / (TP + FN) | Missing positives is costly (disease, fraud) |
| Specificity | TN / (TN + FP) | You care about correctly rejecting negatives |
| F1 score | 2 × Precision × Recall / (Precision + Recall) | Need a balance on imbalanced data |
| ROC-AUC | Area under TPR vs FPR curve | Comparing models across all thresholds |
Quick check: 100 fraud cases, model catches 80, and raises 20 false alarms. Precision = 80 / (80 + 20) = 0.80. Recall = 80 / (80 + 20 missed) = 0.80.
Regression metrics and formulas
| Metric | Formula | Note |
|---|---|---|
| MAE | mean of abs(y − ŷ) | Same unit as target; robust to outliers |
| MSE | mean of (y − ŷ)² | Punishes large errors heavily |
| RMSE | √MSE | Same unit as target; still punishes big errors |
| R² | 1 − SS_res / SS_tot | Share of variance explained; 1 is perfect, can go below 0 |
Here SS_res = Σ(y − ŷ)² and SS_tot = Σ(y − ȳ)², where ȳ is the mean of the actual values.
Bias vs variance
| High bias (underfitting) | High variance (overfitting) | |
|---|---|---|
| Training error | High | Low |
| Validation error | High | Much higher than training |
| Model is | Too simple | Too complex / memorising |
| Example | Straight line on curved data | Very deep tree on small data |
| Fix | More features, more complex model, less regularisation | More data, simpler model, more regularisation |
The goal is the sweet spot where validation error is lowest. Total error is roughly bias² + variance + irreducible noise.
How to fix overfitting
| Fix | How it helps | scikit-learn example |
|---|---|---|
| More training data | Harder to memorise | — |
| Simpler model | Fewer ways to fit noise | max_depth=5 on trees |
| Regularisation | Penalises large weights | Ridge(alpha=1.0), LogisticRegression(C=0.1) |
| Feature selection | Removes noisy inputs | Lasso, SelectKBest |
| Cross-validation | Honest estimate while tuning | cross_val_score(model, X, y, cv=5) |
| Ensembles | Averaging reduces variance | RandomForestClassifier |
| Early stopping / dropout | Stops neural nets memorising | Keras callbacks, Dropout layers |
Common mistake: Saying "add more layers" or "train longer" to fix overfitting. Both usually make it worse. Those help underfitting.
Train, validation and test sets
| Set | Typical share | Used for | Rule |
|---|---|---|---|
| Training | 60–80% | Fitting model parameters | Fit scalers and encoders here only |
| Validation | 10–20% | Comparing models, tuning hyperparameters | Can be replaced by k-fold cross-validation |
| Test | 10–20% | Final, one-time performance estimate | Touch it once, at the end |
Use stratify=y for classification so class proportions match across splits. For time series, split by time, never randomly.
A standard scikit-learn workflow
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split, cross_val_score
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import confusion_matrix, f1_score
X, y = load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, stratify=y, random_state=42
)
model = make_pipeline(StandardScaler(), RandomForestClassifier(random_state=42))
print("CV F1:", cross_val_score(model, X_train, y_train, cv=5, scoring="f1").mean())
model.fit(X_train, y_train)
pred = model.predict(X_test)
print(confusion_matrix(y_test, pred))
print("Test F1:", round(f1_score(y_test, pred), 3))
Notice the order: split first, cross-validate on training data only, then fit and score on the test set once. (Random forests do not need scaling; the scaler is there to show where preprocessing belongs.)
Quick revision checklist
- Can you explain supervised vs unsupervised with one example each?
- Can you write the precision, recall and F1 formulas from memory?
- Can you say which metric you would use for fraud detection, and why?
- Can you spot overfitting from training vs validation error?
- Can you explain why scaling must be fitted on training data only?
Pro tip: Revision only works if the concepts are already in your head from building things. Project-based practice, where you train, evaluate and fix real models, is what makes these tables stick. Then test yourself with our machine learning basics interview questions.
For a refresher on how ML relates to neural networks, see machine learning vs deep learning. If you are still learning the basics, our realistic plan for learning ML fundamentals shows how long each topic takes.
Frequently asked questions
Is there a PDF version of this machine learning cheat sheet?
There is no separate PDF. The page is built to be printed or saved from your browser, and every table fits on a normal page width. Bookmarking it on your phone works well for revision on the way to an interview.
What machine learning topics are asked most in fresher interviews?
Supervised vs unsupervised learning, overfitting and how to fix it, bias vs variance, precision vs recall, the confusion matrix, train-test split and cross-validation. Interviewers also ask you to explain one ML project end to end.
Which metric should I use for imbalanced data?
Avoid plain accuracy. Use precision, recall, F1 or ROC-AUC depending on which error costs more. If missing a positive case is expensive, focus on recall. If false alarms are expensive, focus on precision. PR-AUC is also useful when positives are rare.
What is the difference between a validation set and a test set?
The validation set is used while building the model, to compare models and tune hyperparameters. The test set is kept aside and used once at the very end to estimate real-world performance. If you tune on the test set, your final score is too optimistic.
How should I use this cheat sheet?
Use it for revision after you have learned the topics, not as your first exposure. Cover the right-hand column of each table and try to recall it. Anything you cannot explain in your own words is a topic to go back and study properly.
Want to learn these by building real models? Book a free demo class to see how CodeBegun teaches machine learning through projects, or explore the Artificial Intelligence course.
