Robotics
← Roadmap/Learning

ML Fundamentals

Bias/variance, regression, classification — the basics.

Progress0/9 questions

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

y^\hat{y}model prediction
yytrue label/target
θ\thetamodel parameters (weights)
α\alphalearning rate
λ\lambdaregularization strength
J(θ)J(\theta)cost/loss function over the training set
nnnumber of training examples

Bias-variance decomposition

Expected test error decomposes as Error=Bias2+Variance+Noise\text{Error} = \text{Bias}^2 + \text{Variance} + \text{Noise}.

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

θθαθJ(θ)\theta \leftarrow \theta - \alpha \nabla_\theta J(\theta)

Each step moves parameters opposite the gradient. Too large an α\alpha 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: J(θ)=1n(y^iyi)2J(\theta) = \frac{1}{n}\sum (\hat{y}_i - y_i)^2.

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 λθ22\lambda \lVert \theta \rVert_2^2 to the cost, shrinking all weights smoothly toward zero.

L1 (lasso) adds λθ1\lambda \lVert \theta \rVert_1, driving some weights exactly to zero — a built-in feature selector. Both trade a bit of bias for lower variance.

Classification metrics

Precision=TPTP+FP\text{Precision} = \dfrac{TP}{TP+FP}, Recall=TPTP+FN\quad \text{Recall} = \dfrac{TP}{TP+FN}

F1=2PrecisionRecallPrecision+RecallF_1 = 2 \cdot \dfrac{\text{Precision}\cdot\text{Recall}}{\text{Precision}+\text{Recall}} — 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. λ\lambda, 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.

low variancehigh variancelow biashigh biaserror = bias² + variance + noise
Bias is systematic offset from the target; variance is scatter. Test error decomposes into bias² + variance + noise — reducing one often raises the other (the bias–variance tradeoff).
 High bias (underfit)High variance (overfit)
SymptomHigh train error, high test errorLow train error, high test error
Typical causeModel too simple, too much regularizationModel too complex, too little data
FixMore features, less regularization, bigger modelMore data, more regularization, simpler model
min−∇f zig-zags on an ill-conditioned bowl; Newton/Gauss–Newton rescale by curvature
Gradient descent steps downhill along −∇f. On an elongated (ill-conditioned) cost surface it zig-zags; second-order methods (Newton / Gauss–Newton) rescale by curvature and head more directly to the minimum.

Application focus

Select an application above.

Practice questions (9)