Machine Learning Quizzes
Jerry Xiao Two

Quizzes for Maching Learning Course CS405 and CS329 at SUSTech. (Before 2024 Fall Semester)

Quiz 1

Question

y=Ax+vy=Ax + v, where vv is a Gaussian noise.

  1. What is the optimal solution for xx?
  2. What is the optimal solution for xx if vN(0,R)v \sim \mathcal{N}(0, R)?
  3. What is the optimal solution for xx if vN(0,R)v \sim \mathcal{N}(0, R) and XN(0,aI)X \sim N(0, aI)?
  4. AA and XX are unknown, what is the optimal solution for xx?

Answer

  1. J(x)=12(yAx)T(yAx)J(x) = \frac{1}{2} (y - Ax)^T(y-Ax), Jx=0\frac{\partial J}{\partial x} = 0, x=(ATA)1ATyx = (A^TA)^{-1}A^Ty
  2. J(x)=12(yAx)TR1(yAx)J(x) = \frac{1}{2} (y - Ax)^TR^{-1}(y-Ax), Jx=0\frac{\partial J}{\partial x} = 0, x=(ATR1A)1ATR1yx = (A^TR^{-1}A)^{-1}A^TR^{-1}y
  3. J(x)=12(yAx)TR1(yAx)+12xT(aI)1xJ(x) = \frac{1}{2} (y - Ax)^TR^{-1}(y-Ax) + \frac{1}{2} x^T(aI)^{-1}x, Jx=0\frac{\partial J}{\partial x} = 0, x=(ATR1A+aI)1ATR1yx = (A^TR^{-1}A + aI)^{-1}A^TR^{-1}y
  4. We can distinguish two cases:
    1. For x: J(x)=12(yAx)TR1(yAx)+12xT(aI)1xJ(x) = \frac{1}{2} (y - Ax)^TR^{-1}(y-Ax) + \frac{1}{2} x^T(aI)^{-1}x, Jx=0\frac{\partial J}{\partial x} = 0, x=(ATR1A+aI)1ATR1yx = (A^TR^{-1}A + aI)^{-1}A^TR^{-1}y
    2. For A: YT=XTATY^T = X^TA^T J(A)=12(YXA)TR1(YXA)J(A) = \frac{1}{2} (Y - XA)^TR^{-1}(Y-XA), JA=0\frac{\partial J}{\partial A} = 0, AT=(XR1XT)1XR1YTA^T = (XR^{-1}X^T)^{-1}XR^{-1}Y^T

Quiz 2

Question

Y=AX+ωY = AX + \omega, where ωN(0,Q)\omega \sim \mathcal{N}(0, Q) and XN(μ0,Σ0)X \sim \mathcal{N}(\mu_0, \Sigma_0)

  1. What is p(YX)p(Y|X)?
  2. What is p(Y)p(Y)?
  3. What is p(XY)p(X|Y)?
  4. What is p(YY)p(Y'|Y)?

Answer

  1. p(YX)N(AX,Q)p(Y|X) \sim \mathcal{N}(AX, Q) We regard XX as a constant under conditional probability.
  2. p(Y)p(YX)p(X)dxN(Aμ0,AΣ0AT+Q)p(Y) \sim \int p(Y|X) p(X) d x \sim \mathcal{N}(A\mu_0, A\Sigma_0 A^T + Q).

    var[Y]=var[AX]+var[ω]=AΣ0AT+Qvar[Y] = var[AX] + var[\omega] = A\Sigma_0 A^T + Q

  3. Assume that p(XY)N(m,L)p(X|Y) \sim \mathcal{N}(m, L), then we can use the equality of quadratic from to solve the problems.
    1. p(XY)p(YX)p(X)=N(YAX,Q)N(Xμ0,Σ9)p(X|Y) \sim p(Y|X)p(X) = \mathcal{N}(Y| AX, Q) \mathcal{N}(X| \mu_0, \Sigma_9)
    2. 12(xm)TL1(xm)12(yAx)TQ1(yAx)12(xμ0)TΣ01(xμ0)-\frac{1}{2}(x-m)^T L^{-1}(x-m) \propto -\frac{1}{2}(y-Ax)^T Q^{-1}(y-Ax) -\frac{1}{2}(x-\mu_0)^T \Sigma_0^{-1}(x-\mu_0)
    3. We can get the result:

    L1=ATQ1A+Σ01L1m=ATQ1y+Σ01μ0\begin{aligned} L^{-1} &= A^T Q^{-1} A + \Sigma_0^{-1} \\ L^{-1} m &= A^T Q^{-1} y + \Sigma_0^{-1} \mu_0 \end{aligned}

    1. By applying [A+BCD]1=A1A1B[C1+DA1B]1DA1[A+BCD]^{-1} = A^{-1} - A^{-1}B[C^{-1} + DA^{-1}B]^{-1} D A^{-1}

    L=(IKA)Σ0m=μ0+K(yAμ0)\begin{aligned} L &= (I - KA) \Sigma_0 \\ m &= \mu_0 + K(y - A\mu_0) \end{aligned}

    where K=Σ0AT(ATΣ0A+Q)1K = \Sigma_0 A^T (A^T\Sigma_0A + Q)^{-1}
  4. p(YY)p(YX)p(XY)dxN(Am,ALAT+Q)p(Y'|Y) \sim \int p(Y'|X) p(X|Y) d x \sim \mathcal{N}(Am, AL A^T + Q). The same format as question 2.

Quiz 3

  1. Learning: p(θD)p(Dθ)p(θ)p(\theta|\mathcal{D}) \propto p(\mathcal{D}|\theta)p(\theta)
  2. Prediction: p(DnewD)=p(Dnewθ)p(θD)dθp(\mathcal{D}^{new}|\mathcal{D}) = \int p(\mathcal{D}^{new}|\theta)p(\theta|\mathcal{D})d\theta
  3. Evaluation: p(D)=p(Dθ)p(θ)dθp(\mathcal{D}) = \int p(\mathcal{D}|\theta)p(\theta)d\theta

Question

Given t=Φ(x)ω+vt = \Phi(x) \omega + v where Φ(x)=[1,x,x...,xM]\Phi(x) = [1, x, x..., x^M] and vN(0,β1)v \sim \mathcal{N}(0, \beta^{-1}), D={[x1,...,xN],[t1,...,tN]}\mathcal{D} = \{[x_1,...,x_N], [t_1, ..., t_N]\}

  1. What is the solution of ωML\omega_{ML}?
  2. What is the solution of ωMAP\omega_{MAP} if ωN(0,α1I)\omega \sim \mathcal{N}(0, \alpha^{-1}I)?
  3. What is the predictive distribution if Dnew={xnew,tnew}\mathcal{D}^{new} = \{x^{new}, t^{new}\}?
  4. What is the model evaluation?

Answer

  1. J(ω)=β2(TΦω)T(TΦω)ωML=(ΦTΦ)1ΦTTJ(\omega) = \frac{\beta}{2}(T-\Phi \omega)^T(T-\Phi\omega) \rightarrow \omega_{ML} = (\Phi^T\Phi)^{-1}\Phi^T T
  2. J(ω)=β2(TΦω)T(TΦω)+α2ωTωωMAP=(βΦTΦ+αI)1βΦTTJ(\omega) = \frac{\beta}{2}(T-\Phi\omega)^T(T-\Phi\omega) + \frac{\alpha}{2} \omega^T\omega \rightarrow \omega_{MAP} = (\beta\Phi^T\Phi + \alpha I)^{-1}\beta\Phi^T T
  3. N(Φ(xnew)ωMAP,Φ(xnew)ΣMAPΦ(xnew)T+βI)\mathcal{N}(\Phi(x^{new})\omega_{MAP}, \Phi(x^{new})\Sigma_{MAP}\Phi(x^{new})^T+\beta I)
  4. N(0,α1ΦΦT+β1I)\mathcal{N}(0, \alpha^{-1}\Phi\Phi^T+\beta^{-1}I)

Quiz 4

Question

For y=σ(Φ(x)w)y = \sigma(\Phi(x) w), and D={[x1,...,xN],[t1,...,tN]}\mathcal{D} = \{[x_1,...,x_N], [t_1, ..., t_N]\}, where σ(x)=11+ex\sigma(x) = \frac{1}{1+e^{-x}}.

  1. What is the solution of wMLw_{ML}?
  2. What is the solution of wMAPw_{MAP} if wN(m0,S0)w \sim \mathcal{N}(m_0, S_0)?
  3. What is the predictive distribution if Dnew={xnew,tnew=1}\mathcal{D}^{new} = \{x^{new}, t^{new}=1\}?
  4. What is the model evaluation?

Answer

  1. J(w)=n=1N{tnlogyn+(1tn)log(1yn)} b=J(w)=n=1NϕT(yntn) H=J(w)=n=1Nyn(1yn)ϕnTϕJ(w) = -\sum_{n=1}^N \{t_n \log y_n + (1-t_n) \log(1-y_n)\} \ b = \triangledown J(w) = \sum_{n=1}^N \phi^T(y_n - t_n) \ H = \triangledown \triangledown J(w) = \sum_{n=1}^N y_n(1-y_n) \phi_n^T\phi

    Because σ\sigma is not a linear function, there are no explicit solution to find wMLw_{ML}. We can use the gradient descent method to find the solution.

    w+wH1bw^+ \rightarrow w - H^{-1}b

  2. J(w)=n=1N{tnlogyn+(1tn)log(1yn)}+12(wm0)TS01(wm0)J(w) = -\sum_{n=1}^N \{t_n \log y_n + (1-t_n) \log(1-y_n)\} + \frac{1}{2}(w-m_0)^TS_0^{-1}(w-m_0)

    Therefore,and H=J(w)=n=1Nyn(1yn)ϕnTϕ+S01H = \triangledown \triangledown J(w) =\sum_{n=1}^N y_n(1-y_n) \phi_n^T\phi + S_0^{-1}

  3. p(tnew=1xnew,D)=p(tnew=1w)p(wD)dw=σ(ϕneww)N(wMAP,H1)dwp(t^{new}=1 | x^{new}, \mathcal{D}) = \int p(t^{new}=1|w)p(w|\mathcal{D})dw = \int \sigma(\phi^{new} w) \mathcal{N}(w_{MAP}, H^{-1})dw

    σ(κ(σa2)μa)\sigma(\kappa(\sigma_a^2)\mu_a)

  4. n=1N[tnlnyn+(1tn)ln(1yn)]MAP12(wMAPm0)TS01(wMAPm0)+M2ln2π12lnHMAP\sum_{n=1}^N \left[t_n \ln y_n + (1 - t_n) \ln (1 - y_n)\right]_{\text{MAP}} - \frac{1}{2} (w_\text{MAP}- m_0)^T S_0^{-1}(w_\text{MAP}- m_0)+ \frac{M}{2} \ln 2\pi - \frac{1}{2}\ln |H|_\text{MAP}

Powered by Hexo & Theme Keep
This site is deployed on