MACHINE LEARNING

106403
Back to MACHINE LEARNING

Unit 2: Statistical Decision Theory

  1. Q1c. Ridge regression adds which term to the loss function? (i) L1 norm (ii) Entropy (iii) L2 norm (iv) Cross-entropy20252m

    Unit 2: Statistical Decision Theory

    Ridge regression adds which term to the loss function?
    (i) L1 norm
    (ii) Entropy
    (iii) L2 norm
    (iv) Cross-entropy

    View this question on its own page →
    Worked Solution

    Answer: (iii) L2 norm

    Explanation:

    Ridge Regression (Tikhonov regularization) adds L2 penalty to OLS loss:

    J(w)=∑i=1n(yi−wTxi)2+λ∣∣w∣∣22J(w) = \sum_{i=1}^n (y_i - w^T x_i)^2 + \lambda ||w||_2^2 where ∣∣w∣∣22=∑jwj2||w||_2^2 = \sum_j w_j^2, λ>0\lambda >0

    • Shrinks coefficients toward zero, handles multicollinearity, reduces variance / overfitting.
    • Closed form: wridge=(XTX+λI)−1XTyw_{ridge} = (X^T X + \lambda I)^{-1} X^T y

    Contrast:

    • L1 norm (i) → Lasso regression, induces sparsity/feature selection.
    • Entropy (ii) / Cross-entropy (iv) → used in logistic regression / decision trees, not ridge.

    So ridge = L2.

  2. Q1d. Maximum Likelihood estimation finds (i) Prior probabilities (ii) Parameters that maximize data likelihood (iii) Decision boundaries (iv) Cluster centroids20252m

    Unit 2: Statistical Decision Theory

    Maximum Likelihood estimation finds
    (i) Prior probabilities
    (ii) Parameters that maximize data likelihood
    (iii) Decision boundaries
    (iv) Cluster centroids

    View this question on its own page →
    Worked Solution

    Answer: (ii) Parameters that maximize data likelihood

    Explanation:

    Maximum Likelihood Estimation (MLE):

    θ^MLE=arg⁡max⁡θL(θ)=arg⁡max⁡θp(D∣θ)=arg⁡max⁡θ∏ip(xi∣θ)\hat{\theta}_{MLE} = \arg\max_{\theta} L(\theta) = \arg\max_{\theta} p(D|\theta) = \arg\max_{\theta} \prod_i p(x_i|\theta)

    • Finds parameter values that make observed data most probable under assumed model.
    • Example: For Gaussian, MLE gives sample mean μ^=xˉ\hat{\mu}= \bar{x} and sample variance (biased) σ^2=1n∑(xi−xˉ)2\hat{\sigma}^2 = \frac1n\sum(x_i-\bar{x})^2.
    • Contrast MAP: arg⁡max⁡p(θ∣D)∝p(D∣θ)p(θ)\arg\max p(\theta|D) \propto p(D|\theta)p(\theta) includes prior.

    It does NOT find priors (i), decision boundaries (iii) directly, or cluster centroids (iv) — those are consequences after estimation.

    So (ii) is correct.

  3. Q3(a). A company wants to predict the sales (y) of a product based on its advertising expenditure (x). The observed data for 5 months is: | x (Advertising) | y (Sales) | |-----------------|-----------| | 1 | 3 | | 2 | 4 | | 3 | 2 | | 4 | 5 | | 5 | 7 | Calculate the regression coefficients for the linear regression model: y = w_0 + w_1 x Then, predict the value of y when x = 6.20257m

    Unit 2: Statistical Decision Theory

    A company wants to predict the sales (y) of a product based on its advertising expenditure (x).
    The observed data for 5 months is:

    x (Advertising) y (Sales)
    1 3
    2 4
    3 2
    4 5
    5 7

    Calculate the regression coefficients for the linear regression model:

    y=w0+w1xy = w_0 + w_1 x

    Then, predict the value of y when x = 6.

    View this question on its own page →
    Worked Solution

    Given: n=5n=5, x=[1,2,3,4,5]x=[1,2,3,4,5], y=[3,4,2,5,7]y=[3,4,2,5,7]

    Compute w0w_0 (intercept), w1w_1 (slope) for y=w0+w1xy = w_0 + w_1 x via OLS.

    Formulas: w1=∑(xi−xˉ)(yi−yˉ)∑(xi−xˉ)2w_1 = \frac{\sum (x_i-\bar x)(y_i-\bar y)}{\sum (x_i-\bar x)^2}, w0=yˉ−w1xˉw_0 = \bar y - w_1 \bar x

    • xˉ=(1+2+3+4+5)/5=3\bar x = (1+2+3+4+5)/5 = 3
    • yˉ=(3+4+2+5+7)/5=21/5=4.2\bar y = (3+4+2+5+7)/5 =21/5=4.2
    xix_i yiy_i xi−xˉx_i-\bar x yi−yˉy_i-\bar y (xi−xˉ)(yi−yˉ)(x_i-\bar x)(y_i-\bar y) (xi−xˉ)2(x_i-\bar x)^2
    1 3 -2 -1.2 2.4 4
    2 4 -1 -0.2 0.2 1
    3 2 0 -2.2 0 0
    4 5 1 0.8 0.8 1
    5 7 2 2.8 5.6 4
    Sum numer =9.0=9.0, denom =10=10

    w1=9/10=0.9w_1 = 9/10 =0.9

    w0=4.2−0.9∗3=4.2−2.7=1.5w_0 =4.2 -0.9*3 =4.2-2.7=1.5

    Model: y^=1.5+0.9x\hat y =1.5 +0.9 x

    Prediction at x=6x=6: y^=1.5+0.9∗6=1.5+5.4=6.9≈7\hat y =1.5 +0.9*6 =1.5+5.4=6.9 \approx 7

    Residuals check: y^train=[2.4,3.3,4.2,5.1,6.0]\hat y_{train}=[2.4,3.3,4.2,5.1,6.0], SSE small.

    If using normal equations directly: w=(XTX)−1XTyw=(X^T X)^{-1}X^T y gives same.

  4. Q3b. Given a dataset with two features: X = [[2, 0], [0, 1], [0, 2]]. Compute the covariance matrix, eigenvalues, and the principal components.20257m

    Unit 2: Statistical Decision Theory

    Given a dataset with two features: X = [[2, 0], [0, 1], [0, 2]]. Compute the covariance matrix, eigenvalues, and the principal components.

    View this question on its own page →
    Worked Solution

    Data: X=[200102]X =\begin{bmatrix}2&0\\0&1\\0&2\end{bmatrix}, n=3n=3, d=2d=2

    Step 1: Mean center. xˉ=[(2+0+0)/3,(0+1+2)/3]=[0.667,1]\bar x = [(2+0+0)/3, (0+1+2)/3]=[0.667,1]

    Centered Xc=[1.333−1−0.6670−0.6671]X_c =\begin{bmatrix}1.333&-1\\-0.667&0\\-0.667&1\end{bmatrix}

    Step 2: Covariance C=1n−1XcTXcC = \frac1{n-1} X_c^T X_c (unbiased; if 1/n1/n divide by 3, mention both).

    XcTXc=[1.3332+0.6672+0.66721.333∗(−1)+(−0.667)∗0+(−0.667)∗1sym1+0+1]X_c^T X_c =\begin{bmatrix}1.333^2+0.667^2+0.667^2 &1.333*(-1)+(-0.667)*0+(-0.667)*1\\ sym &1+0+1\end{bmatrix}
    =[2.667−2−22]= \begin{bmatrix}2.667 & -2\\ -2 &2\end{bmatrix}

    Hence:

    • Unbiased (1/(n−1)=1/21/(n-1)=1/2): C=[1.333−1−11]C =\begin{bmatrix}1.333 & -1\\ -1 &1\end{bmatrix}
    • Biased (1/n1/n): Cbiased=[0.889−0.667−0.6670.667]C_{biased}=\begin{bmatrix}0.889 & -0.667\\ -0.667 &0.667\end{bmatrix} (scale by 2/32/3)

    Step 3: Eigenvalues solve ∣C−λI∣=0|C-\lambda I|=0:

    (1.333−λ)(1−λ)−1=0⇒λ2−2.333λ+0.333=0(1.333-\lambda)(1-\lambda)-1=0 \Rightarrow \lambda^2 -2.333\lambda+0.333=0
    λ=2.333±5.444−1.3332=2.333±2.0282\lambda = \frac{2.333\pm\sqrt{5.444-1.333}}{2}= \frac{2.333\pm2.028}{2}
    λ1≈2.18\lambda_1 \approx 2.18, λ2≈0.152\lambda_2 \approx 0.152 (Unbiased)
    For biased version: λ1≈1.454\lambda_1\approx1.454, λ2≈0.102\lambda_2\approx0.102 (2/3 times).

    Explained variance: 93.5%93.5\% by PC1, 6.5%6.5\% by PC2.

    Step 4: Eigenvectors (PCs):
    For λ1=2.18\lambda_1=2.18: (C−λI)v=0⇒−0.847v1−1v2=0⇒v∝[1,−0.847](C-\lambda I)v=0\Rightarrow -0.847 v_1 -1 v_2=0\Rightarrow v\propto[1,-0.847] normalized v1≈[0.763,−0.647]v_1\approx[0.763,-0.647]
    For λ2=0.152\lambda_2=0.152: v2≈[0.647,0.763]v_2\approx[0.647,0.763] orthogonal.

    Normalized PCs (unit): PC1≈[−0.76,0.65]PC1\approx [-0.76,0.65] direction of max variance (roughly along x−yx-y diagonal), PC2PC2 orthogonal.

    Projection Z=XcVZ=X_c V gives reduced 1D representation capturing >93%>93\% variance. First PC is the principal component.