1. Home
  2. Explore
  3. Other
  4. Lecture Introduction and Logistics

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Lecture Introduction and Logistics

  • 29Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Supervised Learning Concepts

Define supervised learning in terms of the training set, hypothesis function, and goal.

29 questions

  1. 1

    Define supervised learning in terms of the training set, hypothesis function, and goal.

    Model answer

    Supervised learning is given a training set of pairs (xi,yi)(x_i, y_i)(xi​,yi​) and finds a hypothesis h:X→Yh: X \to Yh:X→Y that predicts well on new data.

    Explanation

    The training set provides examples; the hypothesis maps inputs to outputs. The goal is to generalize to unseen examples.

  2. 2

    What is a training set?

    Model answer

    A training set is a set of nnn pairs (xi,yi)(x_i, y_i)(xi​,yi​), where xix_ixi​ is an input and yiy_iyi​ is its label or target.

    Explanation

    Each pair is a training example; the set is used to learn the hypothesis.

  3. 3

    What is the hypothesis function hhh in supervised learning?

    Model answer

    The hypothesis hhh is a function h:X→Yh: X \to Yh:X→Y that the algorithm learns to predict outputs from inputs.

    Explanation

    hhh is chosen from a class of functions, e.g., linear functions, to approximate the true mapping.

  4. 4

    Distinguish between classification and regression.

    Model answer

    Classification predicts a discrete output YYY (e.g., cat/no cat), while regression predicts a continuous output YYY (e.g., house price).

    Explanation

    The type of output space determines whether the problem is classification (discrete) or regression (continuous).

  5. 5

    What is the goal of supervised learning regarding new, unseen data?

    Model answer

    The goal is to make accurate predictions on new data drawn from the same distribution as the training data, not just to memorize training examples.

    Explanation

    Generalization to unseen examples is the key objective, which is why we evaluate on test data.

  6. 6

    What is overfitting?

    Model answer

    Overfitting occurs when a model fits the training data too closely, capturing noise, and performs poorly on new data.

    Explanation

    It arises from excessively complex models; modern deep learning sometimes defies this trade-off.

  7. 7

    Write the linear regression hypothesis hθ(x)h_\theta(x)hθ​(x) in expanded form for ddd features.

    Model answer

    hθ(x)=θ0x0+θ1x1+⋯+θdxdh_\theta(x) = \theta_0 x_0 + \theta_1 x_1 + \cdots + \theta_d x_dhθ​(x)=θ0​x0​+θ1​x1​+⋯+θd​xd​, with x0=1x_0 = 1x0​=1.

    Explanation

    This is an affine function made linear by the convention that x0=1x_0=1x0​=1. The parameters θj\theta_jθj​ are weights.

  8. 8

    Why do we set x0=1x_0 = 1x0​=1 in linear regression?

    Model answer

    To absorb the bias term θ0\theta_0θ0​ into the linear form, making the hypothesis hθ(x)=∑j=0dθjxjh_\theta(x) = \sum_{j=0}^d \theta_j x_jhθ​(x)=∑j=0d​θj​xj​.

    Explanation

    This simplifies notation by treating the intercept as a weight on a constant feature.

  9. 9

    How many parameters does a linear regression model with ddd features have?

    Model answer

    d+1d+1d+1 parameters: θ0,θ1,…,θd\theta_0, \theta_1, \dots, \theta_dθ0​,θ1​,…,θd​.

    Explanation

    The extra parameter (compared to number of features) is due to the bias term θ0\theta_0θ0​ corresponding to x0=1x_0=1x0​=1.

  10. 10

    Represent the training data as a matrix XXX. What are its dimensions?

    Model answer

    XXX is an n×(d+1)n \times (d+1)n×(d+1) matrix, where nnn is number of training examples and each row contains xi0=1x_{i0}=1xi0​=1, xi1,…,xidx_{i1}, \dots, x_{id}xi1​,…,xid​.

    Explanation

    Each row is a feature vector for one example; the column of ones accounts for the bias.

  11. 11

    What is a feature vector in the context of linear regression?

    Model answer

    A feature vector is a (d+1)(d+1)(d+1)-dimensional vector [1,x1,x2,…,xd]T[1, x_1, x_2, \dots, x_d]^T[1,x1​,x2​,…,xd​]T representing a single training example with the bias term included.

    Explanation

    Features are the input attributes used to make predictions; the leading 1 is a convention.

  12. 12

    Write the least squares cost function J(θ)J(\theta)J(θ) for linear regression over nnn training examples.

    Model answer

    J(θ)=12∑i=1n(hθ(xi)−yi)2J(\theta) = \frac{1}{2} \sum_{i=1}^n (h_\theta(x_i) - y_i)^2J(θ)=21​∑i=1n​(hθ​(xi​)−yi​)2.

    Explanation

    This sum of squared errors penalizes large deviations; the 12\frac1221​ simplifies derivatives.

  13. 13

    Why is the 12\frac1221​ factor included in the least squares cost function?

    Model answer

    To cancel the factor of 2 that appears when taking the derivative, simplifying the gradient expression.

    Explanation

    The minimizer does not depend on constant scaling, so the 12\frac1221​ is a convenience for optimization.

  14. 14

    Interpret the cost function J(θ)J(\theta)J(θ) in terms of prediction errors.

    Model answer

    J(θ)J(\theta)J(θ) measures the total squared difference between predictions hθ(xi)h_\theta(x_i)hθ​(xi​) and true labels yiy_iyi​, penalizing larger errors more.

    Explanation

    Minimizing JJJ encourages predictions to be close to the actual values on the training set.

  15. 15

    For linear regression, is the cost function J(θ)J(\theta)J(θ) convex? What does that imply about local minima?

    Model answer

    Yes, J(θ)J(\theta)J(θ) is convex (bowl-shaped), so any local minimum is also a global minimum, and gradient descent can find the optimal parameters.

    Explanation

    Convexity ensures a unique global optimum; this is not true for more complex models like neural networks.

  16. 16

    Derive the partial derivative ∂∂θjJ(θ)\frac{\partial}{\partial \theta_j} J(\theta)∂θj​∂​J(θ) for linear regression.

    Model answer

    ∂∂θjJ(θ)=∑i=1n(hθ(xi)−yi)xij\frac{\partial}{\partial \theta_j} J(\theta) = \sum_{i=1}^n (h_\theta(x_i) - y_i) x_{ij}∂θj​∂​J(θ)=∑i=1n​(hθ​(xi​)−yi​)xij​, where xijx_{ij}xij​ is the jjj-th feature of the iii-th example.

    Explanation

    The derivative follows from applying the chain rule: the 12\frac1221​ cancels with the 2 from the derivative of the square, and ∂∂θjhθ(xi)=xij\frac{\partial}{\partial \theta_j} h_\theta(x_i) = x_{ij}∂θj​∂​hθ​(xi​)=xij​.

  17. 17

    Write the batch gradient descent update rule for linear regression parameters θj\theta_jθj​.

    Model answer

    θj(t+1)=θj(t)−α∑i=1n(hθ(xi)−yi)xij\theta_j^{(t+1)} = \theta_j^{(t)} - \alpha \sum_{i=1}^n (h_\theta(x_i) - y_i) x_{ij}θj(t+1)​=θj(t)​−α∑i=1n​(hθ​(xi​)−yi​)xij​, where α\alphaα is the learning rate.

    Explanation

    This updates each parameter in the direction of steepest descent using all training examples.

  18. 18

    What is the role of the learning rate α\alphaα in gradient descent?

    Model answer

    The learning rate controls the step size: how much we adjust parameters in the direction of the negative gradient at each iteration.

    Explanation

    A proper α\alphaα ensures convergence; too large can overshoot, too small makes progress slow.

  19. 19

    What happens if the learning rate is too large? Too small?

    Model answer

    Too large: the algorithm may overshoot the minimum and diverge. Too small: convergence is very slow, requiring many iterations.

    Explanation

    The ideal α\alphaα balances speed and stability; practical methods often decay the learning rate over time.

  20. 20

    How do we typically decide when to stop gradient descent?

    Model answer

    We stop when the update magnitude (e.g., ∥θ(t+1)−θ(t)∥\|\theta^{(t+1)} - \theta^{(t)}\|∥θ(t+1)−θ(t)∥) becomes smaller than a tolerance, or when the cost function stops decreasing significantly.

    Explanation

    For convex problems, small gradient indicates near-optimum; for non-convex, we often run a fixed number of steps or monitor validation error.

  21. 21

    What is stochastic gradient descent (SGD) and how does it differ from batch gradient descent?

    Model answer

    SGD uses a single randomly chosen training example per update instead of the entire training set. This makes each step noisy but much faster.

    Explanation

    SGD can escape shallow local minima and is more efficient for large datasets, though it may never exactly converge.

  22. 22

    What is mini-batch gradient descent?

    Model answer

    Mini-batch gradient descent uses a small random subset (mini-batch) of B<nB < nB<n examples per update, balancing gradient quality and computational cost.

    Explanation

    Typical mini-batch sizes are 32–256; modern hardware processes mini-batches efficiently in parallel.

  23. 23

    How does batch size affect the gradient estimate and computational cost?

    Model answer

    Larger batch size gives a more accurate gradient estimate but requires more computation per update. Smaller batches are noisier but allow more frequent updates.

    Explanation

    There is a trade-off: mini-batches offer a practical compromise, often with diminishing returns beyond a certain size.

  24. 24

    Why is mini-batch gradient descent commonly used in modern machine learning?

    Model answer

    Mini-batching leverages parallel hardware (GPUs) to process multiple examples simultaneously, reduces noise compared to SGD, and avoids the high cost of full-batch updates on large datasets.

    Explanation

    It provides a good balance of efficiency and convergence stability, and is supported natively in frameworks like PyTorch and TensorFlow.

  25. 25

    What is the normal equation for linear regression?

    Model answer

    The normal equation is θ=(XTX)−1XTy\theta = (X^T X)^{-1} X^T yθ=(XTX)−1XTy, which gives the closed-form solution that minimizes the least squares cost.

    Explanation

    It avoids iterative gradient descent but requires inverting a (d+1)×(d+1)(d+1)\times(d+1)(d+1)×(d+1) matrix, which is costly for large ddd.

  26. 26

    For a convex cost function like linear regression’s, why does gradient descent converge to the global minimum?

    Model answer

    Convex functions have no local minima other than the global minimum, and gradient descent follows the gradient to the unique optimum (with appropriate learning rate).

    Explanation

    The bowl-shaped surface ensures that any downhill direction leads to the same bottom; this property fails for non-convex models.

  27. 27

    Explain the trade-off between using a large or small learning rate in practice.

    Model answer

    A large learning rate speeds up initial progress but risks divergence; a small learning rate is stable but slow. Users often decay the learning rate or use adaptive methods.

    Explanation

    The optimal learning rate depends on the problem; common heuristics include a constant small value or scheduling (e.g., step decay).

  28. 28

    How does overfitting relate to training error vs. test error?

    Model answer

    Overfitting occurs when training error is low but test error is high, because the model has learned noise specific to the training set rather than general patterns.

    Explanation

    Regularization and validation are used to mitigate overfitting; modern models sometimes interpolate data yet generalize well.

  29. 29

    What is the hypothesis class in linear regression?

    Model answer

    The hypothesis class is the set of all linear (affine) functions parameterized by θ\thetaθ, i.e., hθ(x)=θTxh_\theta(x) = \theta^T xhθ​(x)=θTx with x0=1x_0=1x0​=1.

    Explanation

    This restriction from all possible functions makes the problem tractable; the number of parameters d+1d+1d+1 determines model complexity.

1 of 29
Question 1 of 29

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent