ML Fundamentals
Bias/variance, regression, classification — the basics.
Prerequisites
Why it matters in robotics
Machine-learning fundamentals underpin every learned component of a modern robot: perception models, learned state estimators, and control policies. Core ideas like how a model can fit its training data too closely and fail on new data, how to penalize overly complex models, how to shape and scale input features, and how to fit a curve or a decision boundary to data by minimizing error decide whether a learned system works in the real world or just memorizes its training set. These fundamentals are the groundwork beneath deep learning, imitation learning, and reinforcement learning.
What to study
- ✓Bias-variance tradeoff, overfitting/underfitting, and train/validation/test splits with cross-validation
- ✓Linear and logistic regression: cost functions, gradient descent, and decision boundaries
- ✓Regularization (L1/L2) and feature scaling to control model complexity
- ✓Evaluation metrics: MSE/R² for regression, accuracy/precision/recall/confusion matrix for classification
Where to study
Cheatsheet
Symbols used below
Bias-variance decomposition
Expected test error decomposes as .
High bias underfits (model too simple, misses the pattern); high variance overfits (model too flexible, fits noise). More data mainly reduces variance; a better model class reduces bias.
Gradient descent update
Each step moves parameters opposite the gradient. Too large an overshoots or diverges; too small converges slowly. On ill-conditioned (elongated) cost surfaces, plain gradient descent zig-zags.
Linear & logistic regression costs
Linear regression minimizes mean squared error: .
Logistic regression minimizes cross-entropy (log loss) over a sigmoid output, producing a probability and a linear decision boundary in feature space.
Regularization
L2 (ridge) adds to the cost, shrinking all weights smoothly toward zero.
L1 (lasso) adds , driving some weights exactly to zero — a built-in feature selector. Both trade a bit of bias for lower variance.
Classification metrics
,
— the metric to watch under class imbalance, since accuracy alone can hide a model that just predicts the majority class.
Train/validation/test & cross-validation
Train on the training split, tune hyperparameters (e.g. , model capacity) on validation, and report final performance only on a held-out test set touched once.
K-fold cross-validation rotates the validation fold across the training data to get a more stable estimate when data is limited.
| High bias (underfit) | High variance (overfit) | |
|---|---|---|
| Symptom | High train error, high test error | Low train error, high test error |
| Typical cause | Model too simple, too much regularization | Model too complex, too little data |
| Fix | More features, less regularization, bigger model | More data, more regularization, simpler model |
Application focus
Practice questions (9)
- Computing F1 from a confusion matrixmedium
- Diagnosing and addressing the bias-variance tradeoffmedium
- Explain SVM, margin, and its lossInterviewmedium
- What is hinge loss?Interviewmedium
- Different kinds of losses, and multi-class lossInterviewmedium
- How do you select features?Interviewmedium
- What is SGD, and why 'stochastic'?Interviewmedium
- Handling a lack of labeled dataInterviewmedium
- Weight initialization, and why randomInterviewmedium