Docsity

CS229 Machine Learning Study Notes – Key Algorithms, Math Foundations & Exam Review, Exams of Physics

Toggle sidebar
bg1
CS229 Machine Learning
Study Notes – Key
Algorithms, Math
Foundations & Exam Review
Question 1: In the context of supervised learning, what is the
primary goal of the learning algorithm?
A) To discover hidden patterns and structures in unlabeled data.
B) To learn a mapping function from input features to a target
output variable.
C) To find the optimal policy for an agent interacting with an
environment.
D) To reduce the dimensionality of the input data for visualization.
Answer: B) To learn a mapping function from input features
to a target output variable.
Rationale: Supervised learning is defined by the presence of labeled
training data, where each input has a corresponding correct output.
The primary goal is to learn a function that can accurately predict
the output for new, unseen inputs. Option A describes unsupervised
learning, while Option C describes reinforcement learning. Option
D is a technique often used in unsupervised learning, not the
primary goal of supervised learning.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28

Partial preview of the text

Download CS229 Machine Learning Study Notes – Key Algorithms, Math Foundations & Exam Review and more Exams Physics in PDF only on Docsity!

CS229 Machine Learning

Study Notes – Key

Algorithms, Math

Foundations & Exam Review

Question 1: In the context of supervised learning, what is the primary goal of the learning algorithm? A) To discover hidden patterns and structures in unlabeled data. B) To learn a mapping function from input features to a target output variable. C) To find the optimal policy for an agent interacting with an environment. D) To reduce the dimensionality of the input data for visualization. Answer: B) To learn a mapping function from input features to a target output variable. Rationale: Supervised learning is defined by the presence of labeled training data, where each input has a corresponding correct output. The primary goal is to learn a function that can accurately predict the output for new, unseen inputs. Option A describes unsupervised learning, while Option C describes reinforcement learning. Option D is a technique often used in unsupervised learning, not the primary goal of supervised learning.

Question 2: Which of the following is a key difference between linear regression and logistic regression? A) Linear regression predicts continuous values, while logistic regression predicts discrete values. B) Linear regression uses a squared error cost function, while logistic regression uses a cross-entropy cost function. C) Linear regression is a classification algorithm, while logistic regression is a regression algorithm. D) Linear regression has a closed-form solution, while logistic regression does not. Answer: B) Linear regression uses a squared error cost function, while logistic regression uses a cross-entropy cost function. Rationale: This is the most fundamental difference. Linear regression minimizes the sum of squared errors (e.g., Mean Squared Error), assuming a Gaussian distribution of errors. Logistic regression, used for binary classification, minimizes the cross- entropy (or log-loss) cost function, which is derived from the principle of maximum likelihood. Option A is partially true but imprecise (logistic regression predicts probabilities, which are continuous). Option C is false. Option D is generally true (linear regression has a closed-form Normal Equation) but the cost function difference is the more defining characteristic of their functional forms.

Answer: C) A way to implicitly map data to a higher- dimensional space without explicitly computing the coordinates. Rationale: The "kernel trick" is a powerful technique used in SVMs to solve non-linear classification problems. It involves replacing the dot product in the SVM's objective function with a kernel function. This kernel function allows the algorithm to operate in a high- dimensional feature space without ever calculating the coordinates of the data in that space, which can be computationally infeasible. This enables SVMs to find non-linear decision boundaries efficiently. Question 5: Which of the following statements is TRUE about Principal Component Analysis (PCA)? A) It is a supervised learning technique for feature selection. B) It seeks to find the directions (principal components) that maximize the variance of the data. C) It is primarily used to improve the performance of a classification model. D) It requires the data to be from a non-linear manifold. Answer: B) It seeks to find the directions (principal components) that maximize the variance of the data. Rationale: PCA is a dimensionality reduction technique. Its goal is to find a new set of orthogonal axes (principal components) in the data space. The first principal component is the direction of maximum variance in the data; the second is the direction of

maximum variance orthogonal to the first, and so on. By projecting the data onto these components, one can reduce dimensionality while preserving as much of the data's variance as possible. It is an unsupervised, not supervised, technique. Question 6: In linear regression, what does the normal equation θ=(XTX)−1XTy θ =( XTX )−1 XTy compute? A) The gradient of the cost function. B) The closed-form solution for the parameter vector that minimizes the squared error. C) The regularized parameter vector for L2 penalty. D) The projection of y y onto the null space of X X. Answer: B) The closed-form solution for the parameter vector that minimizes the squared error. Rationale: The normal equation is derived by setting the gradient of the least-squares cost function to zero. It gives the optimal parameter vector θθ directly, without iterative optimization, provided XTXXTX is invertible. It does not include regularization unless modified, and it is not merely the gradient. Question 7: Which of the following is the main assumption of the probabilistic interpretation of linear regression? A) The target variable is binary. B) The errors ϵ(i) ϵ ( i ) are independent and identically distributed according to a Gaussian distribution with zero mean.

Question 9: What is the role of the learning rate α α in gradient descent? A) It controls the number of features used in the model. B) It determines the step size taken in the direction of the negative gradient. C) It sets the regularization strength. D) It defines the batch size for stochastic gradient descent. Answer: B) It determines the step size taken in the direction of the negative gradient. Rationale: The learning rate αα scales the gradient update

θ:=θ−α ∇ θJ(θ)θ:=θ−α ∇ θJ(θ). A small αα leads to slow convergence,

while a large αα can cause divergence or oscillation. It is not a regularization parameter or batch-size setting. Question 10: Which of the following is a key property of the Newton’s method for optimization? A) It uses only first-order gradient information. B) It uses second-order information via the Hessian matrix. C) It is guaranteed to converge for non-convex functions. D) It requires a fixed learning rate. Answer: B) It uses second-order information via the Hessian matrix. Rationale: Newton’s method updates parameters using

θ:=θ−H−1 ∇ θJ(θ)θ:=θ−H−1 ∇ θJ(θ), where HH is the Hessian. This

second-order information often yields faster convergence near the optimum but can be computationally expensive and is not guaranteed for non-convex problems. Question 11: In the context of generalized linear models (GLMs), which distribution corresponds to linear regression? A) Bernoulli distribution. B) Gaussian distribution. C) Poisson distribution. D) Exponential distribution. Answer: B) Gaussian distribution. Rationale: In GLMs, linear regression assumes the response variable is Gaussian (normal), logistic regression assumes Bernoulli, and Poisson regression assumes Poisson. The choice of distribution determines the link function and the form of the hypothesis. Question 12: What is the primary difference between generative and discriminative learning algorithms? A) Generative models learn P(y∣x) P ( y ∣ x ) directly, while discriminative models learn P(x∣y) P ( x ∣ y ). B) Generative models learn P(x∣y) P ( x ∣ y ) and P(y) P ( y ), while discriminative models learn P(y∣x) P ( y ∣ x ) directly.

Question 14: Which of the following is TRUE about Naive Bayes? A) It assumes all features are independent given the class label. B) It is a discriminative model. C) It cannot handle categorical features. D) It requires the features to be Gaussian. Answer: A) It assumes all features are independent given the class label. Rationale: The “naive” assumption in Naive Bayes is conditional independence of features given the class:

P(x1,…,xn ∣ y)=∏iP(xi ∣ y)P(x 1 ,…,xn ∣ y)=∏iP(xi ∣ y). This simplifies

computation but is often violated in practice. Naive Bayes is a generative model. Question 15: In Support Vector Machines, what is the margin? A) The number of support vectors. B) The distance between the decision boundary and the closest data points from either class. C) The regularization parameter. D) The kernel width. Answer: B) The distance between the decision boundary and the closest data points from either class. Rationale: The margin is the distance from the separating hyperplane to the nearest training examples (support vectors). SVMs aim to maximize this margin, which improves generalization. The

regularization parameter CC controls the trade-off between margin maximization and training error. Question 16: What does the SVM parameter C C control? A) The kernel type. B) The trade-off between maximizing the margin and minimizing classification error. C) The number of support vectors. D) The dimensionality of the feature space. Answer: B) The trade-off between maximizing the margin and minimizing classification error. Rationale: A large CC penalizes misclassifications heavily, leading to a smaller margin and potential overfitting. A small CC allows more margin violations, producing a wider margin and a more regularized model. CC is not the kernel parameter. Question 17: Which kernel function corresponds to an infinite- dimensional feature space? A) Linear kernel. B) Polynomial kernel. C) Radial Basis Function (RBF) kernel. D) Sigmoid kernel. Answer: C) Radial Basis Function (RBF) kernel.

A) Sigmoid. B) Tanh. C) ReLU (Rectified Linear Unit). D) Step function. Answer: C) ReLU (Rectified Linear Unit). Rationale: ReLU f(z)=max(0,z) f(z)=max( 0 ,z) has a gradient of 0 for negative inputs and 1 for positive inputs, which helps gradients flow better than sigmoid or tanh, whose gradients saturate. ReLU is widely used in deep networks. Question 20: What is the bias-variance tradeoff? A) A tradeoff between model accuracy and training time. B) A tradeoff between underfitting (high bias) and overfitting (high variance). C) A tradeoff between the number of features and the number of samples. D) A tradeoff between regularization and learning rate. Answer: B) A tradeoff between underfitting (high bias) and overfitting (high variance). Rationale: High-bias models are too simple and underfit; high- variance models are too complex and overfit. The goal is to choose model complexity that balances bias and variance to minimize expected test error. This is a central concept in machine learning.

Question 21: Which of the following techniques is used to reduce variance in a machine learning model? A) Adding more features. B) Increasing model complexity. C) Regularization. D) Reducing training data. Answer: C) Regularization. Rationale: Regularization (L1/L2) penalizes large weights, reducing model complexity and variance, which helps prevent overfitting. Adding features or increasing complexity typically increases variance. Reducing training data also increases variance. Question 22: In decision trees, what is the purpose of pruning? A) To increase the depth of the tree. B) To reduce overfitting by removing branches that have little predictive power. C) To handle missing values. D) To convert the tree into a random forest. Answer: B) To reduce overfitting by removing branches that have little predictive power. Rationale: Pruning simplifies a fully grown decision tree by removing branches that do not improve validation performance. This reduces variance and improves generalization. It is not used to increase depth or handle missing values.

Rationale: K-means minimizes the within-cluster sum of squares

(WCSS): ∑i=1k∑x ∈ Ci ∥ x−μi ∥ 2 ∑i= 1 k∑x ∈ Ci ∥ x−μi ∥ 2. It alternates

between assigning points to the nearest centroid and updating centroids. It is not a likelihood-based method like GMMs. Question 25: What is a key limitation of k-means clustering? A) It cannot handle high-dimensional data. B) It assumes clusters are spherical and of similar size. C) It always finds the global optimum. D) It requires labeled data. Answer: B) It assumes clusters are spherical and of similar size. Rationale: K-means uses Euclidean distance and assigns points to the nearest centroid, which implicitly assumes convex, isotropic clusters. It can perform poorly on elongated or irregularly shaped clusters. It is unsupervised and does not guarantee a global optimum. Question 26: In a Gaussian Mixture Model (GMM), what algorithm is commonly used to estimate the parameters? A) Gradient descent. B) The Expectation-Maximization (EM) algorithm.

C) Newton’s method. D) Backpropagation. Answer: B) The Expectation-Maximization (EM) algorithm. Rationale: GMMs are trained using EM, which iteratively computes responsibilities (E-step) and updates parameters (M-step) to maximize the likelihood. EM is a general approach for latent variable models and is not the same as gradient descent. Question 27: What is the primary goal of Principal Component Analysis (PCA)? A) To maximize the likelihood of the data under a Gaussian model. B) To find a lower-dimensional representation that preserves the most variance. C) To cluster the data into distinct groups. D) To perform classification. Answer: B) To find a lower-dimensional representation that preserves the most variance. Rationale: PCA projects data onto the top principal components, which are the directions of maximum variance. It is an unsupervised dimensionality reduction technique, not a clustering or classification method, though it can be used as preprocessing.

models). The choice depends on the amount and mechanism of missingness. Question 30: In the context of learning theory, what does the VC dimension measure? A) The number of training examples required for perfect learning. B) The capacity or expressive power of a hypothesis class. C) The computational complexity of an algorithm. D) The variance of a model. Answer: B) The capacity or expressive power of a hypothesis class. Rationale: The VC (Vapnik-Chervonenkis) dimension is the maximum number of points that can be shattered by a hypothesis class. It quantifies the richness of the class and is used in generalization bounds. It is not a measure of sample size or computational cost. Question 31: According to the bias-variance decomposition, what happens to test error as model complexity increases beyond the optimal point? A) It continues to decrease. B) It remains constant.

C) It increases due to increasing variance. D) It decreases due to decreasing bias. Answer: C) It increases due to increasing variance. Rationale: As complexity increases, bias decreases but variance increases. Beyond the optimal complexity, the increase in variance dominates, causing test error to rise (overfitting). The optimal point minimizes the sum of bias squared, variance, and irreducible error. Question 32: What is the purpose of cross-validation in machine learning? A) To train the model on all data. B) To estimate the generalization performance of a model. C) To increase the number of features. D) To reduce the training time. Answer: B) To estimate the generalization performance of a model. Rationale: Cross-validation (e.g., k-fold) partitions data into training and validation sets multiple times to estimate how well a model generalizes to unseen data. It is used for model selection and hyperparameter tuning, not for training on all data at once. Question 33: In reinforcement learning, what is the role of the discount factor γ γ?