跳到主要内容

東京大学 情報理工学系研究科 コンピュータ科学専攻 2020年8月実施 専門科目 問題4

Author

zephyr

Description

Let R\mathbb{R} be the set of real numbers. Denote by T\mathbf{T} the transposition operator of a vector and a matrix. When w=(w1,w2,,wd)TRd\mathbf{w} = (w_1, w_2, \ldots, w_d)^\mathbf{T} \in \mathbb{R}^d is a dd-dimensional column vector, the norm w2\|\mathbf{w}\|_2 is defined by w2=w12+w22++wd2\|\mathbf{w}\|_2 = \sqrt{w_1^2 + w_2^2 + \ldots + w_d^2}. Define the inner product of two column vectors x1,x2Rd\mathbf{x}_1, \mathbf{x}_2 \in \mathbb{R}^d as x1Tx2R\mathbf{x}_1^\mathbf{T} \mathbf{x}_2 \in \mathbb{R}. For a d×dd \times d matrix ARd×d\mathbf{A} \in \mathbb{R}^{d \times d}, define wA=wTAw\|\mathbf{w}\|_{\mathbf{A}} = \sqrt{\mathbf{w}^\mathbf{T} \mathbf{A} \mathbf{w}}. Let tr(B)\mathbf{tr}(\mathbf{B}) be the trace of the matrix B\mathbf{B}.

Consider the problem of predicting a real-valued label yRy \in \mathbb{R} from a dd-dimensional real vector xRd\mathbf{x} \in \mathbb{R}^d. For learning a predictor, suppose that nn training samples

{(xi,yi)xiRd,yiR,i=1,2,,n}\{(\mathbf{x}_i, y_i) \mid \mathbf{x}_i \in \mathbb{R}^d, y_i \in \mathbb{R}, i = 1, 2, \ldots, n\}

are given where (xi,yi)(\mathbf{x}_i, y_i) means that yiy_i is the real-valued label of xi\mathbf{x}_i. In addition, by using a dd-dimensional vector wRd\mathbf{w}^* \in \mathbb{R}^d and observational noise ϵi(i=1,2,,n)\epsilon_i (i = 1, 2, \ldots, n) that is independent and identically distributed, assume the data generation process as

yi=wTxi+ϵi(i=1,2,,n),y_i = \mathbf{w}^{*\mathbf{T}} \mathbf{x}_i + \epsilon_i \quad (i = 1, 2, \ldots, n),

where the expectation E[ϵi]=0\mathbb{E}[\epsilon_i] = 0 and variance V[ϵi]=σ2>0(i=1,,n)\mathbb{V}[\epsilon_i] = \sigma^2 > 0 \quad (i = 1, \ldots, n). Let us introduce the symbols

X=[x1,,xn]TRn×d,Y=[y1,,yn]TRn,ϵ=[ϵ1,,ϵn]TRn.\mathbf{X} = [\mathbf{x}_1, \ldots, \mathbf{x}_n]^\mathbf{T} \in \mathbb{R}^{n \times d}, \quad \mathbf{Y} = [y_1, \ldots, y_n]^\mathbf{T} \in \mathbb{R}^n, \quad \mathbf{\epsilon} = [\epsilon_1, \ldots, \epsilon_n]^\mathbf{T} \in \mathbb{R}^n.

We also use the symbol Φ=1nXTXRd×d\mathbf{\Phi} = \frac{1}{n} \mathbf{X}^\mathbf{T} \mathbf{X} \in \mathbb{R}^{d \times d} where Φ\mathbf{\Phi} is assumed to be a regular matrix. The expectation over the observational noises is expressed by Eϵ[]\mathbb{E}_{\mathbf{\epsilon}}[\cdot].

We formulate the learning of a predictor f(x)=w^Txf(\mathbf{x}) = \hat{\mathbf{w}}^\mathbf{T} \mathbf{x} as the following optimization problem.

w^=argminwRdL(w)\mathbf{\hat{w}} = \mathop{\arg\min}\limits_{\mathbf{w} \in \mathbb{R}^d} L(\mathbf{w}) L(w)=12ni=1n(yiwTxi)2=12nYXw22.L(\mathbf{w}) = \frac{1}{2n} \sum_{i=1}^{n} (y_i - \mathbf{w}^\mathbf{T} \mathbf{x}_i)^2 = \frac{1}{2n} \|\mathbf{Y} - \mathbf{Xw}\|_2^2.

Answer the following questions. Describe not only an answer but also the derivation process.

(1) Express w^\mathbf{\hat{w}} using X,Y,Φ\mathbf{X}, \mathbf{Y}, \mathbf{\Phi}, and nn.

(2) Suppose we wish to express Eϵ[L(w)]\mathbb{E}_{\mathbf{\epsilon}}[L(\mathbf{w})] in the form of 12wwA2+b\frac{1}{2} \|\mathbf{w} - \mathbf{w}^*\|_{\mathbf{A}}^2 + b. Express the matrix ARd×d\mathbf{A} \in \mathbb{R}^{d \times d} and the positive real number b>0b > 0 using Φ\mathbf{\Phi} and σ2\sigma^2.

(3) Suppose we wish to express Eϵ[L(w^)]Eϵ[L(w)]\mathbb{E}_{\mathbf{\epsilon}}[L(\hat{\mathbf{w}})] - \mathbb{E}_{\mathbf{\epsilon}}[L(\mathbf{w^*})] in the form of σ22ntr(B)\frac{\sigma^2}{2n} \mathbf{tr}(\mathbf{B}). Express the matrix BRd×d\mathbf{B} \in \mathbb{R}^{d \times d} using the matrix X\mathbf{X}.

(4) Explain what problem arises when Φ\mathbf{\Phi} is not a regular matrix and suggest a way to remedy the problem.

Kai

(1)

To find the optimal weight vector w^\mathbf{\hat{w}}, we minimize the loss function L(w)L(\mathbf{w}) defined as:

L(w)=12ni=1n(yiwTxi)2=12nYXw22.L(\mathbf{w}) = \frac{1}{2n} \sum_{i=1}^{n} (y_i - \mathbf{w}^\mathbf{T} \mathbf{x}_i)^2 = \frac{1}{2n} \|\mathbf{Y} - \mathbf{Xw}\|_2^2.

To minimize L(w)L(\mathbf{w}), we take the derivative of L(w)L(\mathbf{w}) with respect to w\mathbf{w} and set it to zero:

L(w)=1nXT(YXw)=0.\nabla L(\mathbf{w}) = -\frac{1}{n} \mathbf{X}^\mathbf{T} (\mathbf{Y} - \mathbf{Xw}) = 0.

Solving for w\mathbf{w} gives:

XTY=XTXw.\mathbf{X}^\mathbf{T} \mathbf{Y} = \mathbf{X}^\mathbf{T} \mathbf{X} \mathbf{w}.

Thus, the optimal weight vector w^\mathbf{\hat{w}} is:

w^=(XTX)1XTY=Φ1(1nXTY).\mathbf{\hat{w}} = (\mathbf{X}^\mathbf{T} \mathbf{X})^{-1} \mathbf{X}^\mathbf{T} \mathbf{Y} = \mathbf{\Phi}^{-1} \left( \frac{1}{n} \mathbf{X}^\mathbf{T} \mathbf{Y} \right).

(2)

To express Eϵ[L(w)]\mathbb{E}_{\mathbf{\epsilon}}[L(\mathbf{w})], we first express L(w)L(\mathbf{w}):

L(w)=12n(YXw)T(YXw).L(\mathbf{w}) = \frac{1}{2n} (\mathbf{Y} - \mathbf{Xw})^\mathbf{T} (\mathbf{Y} - \mathbf{Xw}).

Using the data generation model yi=wTxi+ϵiy_i = \mathbf{w}^{*\mathbf{T}} \mathbf{x}_i + \epsilon_i, we can write Y=Xw+ϵ\mathbf{Y} = \mathbf{X} \mathbf{w}^* + \mathbf{\epsilon}. Then:

Eϵ[L(w)]=12nEϵ[(Xw+ϵXw)T(Xw+ϵXw)].\mathbb{E}_{\mathbf{\epsilon}}[L(\mathbf{w})] = \frac{1}{2n} \mathbb{E}_{\mathbf{\epsilon}}\left[(\mathbf{X} \mathbf{w}^* + \mathbf{\epsilon} - \mathbf{X} \mathbf{w})^\mathbf{T} (\mathbf{X} \mathbf{w}^* + \mathbf{\epsilon} - \mathbf{X} \mathbf{w})\right].

Expanding and using the properties of expectation:

Eϵ[L(w)]=12n[(ww)TXTX(ww)+Eϵ[ϵTϵ]].\mathbb{E}_{\mathbf{\epsilon}}[L(\mathbf{w})] = \frac{1}{2n} \left[(\mathbf{w} - \mathbf{w}^*)^\mathbf{T} \mathbf{X}^\mathbf{T} \mathbf{X} (\mathbf{w} - \mathbf{w}^*) + \mathbb{E}_{\mathbf{\epsilon}}[\mathbf{\epsilon}^\mathbf{T} \mathbf{\epsilon}]\right].

Since E[ϵ]=0\mathbb{E}[\mathbf{\epsilon}] = 0 and E[ϵϵT]=σ2I\mathbb{E}[\mathbf{\epsilon}\mathbf{\epsilon}^\mathbf{T}] = \sigma^2 \mathbf{I}, we have:

Eϵ[L(w)]=12wwΦ2+σ22.\mathbb{E}_{\mathbf{\epsilon}}[L(\mathbf{w})] = \frac{1}{2} \|\mathbf{w} - \mathbf{w}^*\|_{\mathbf{\Phi}}^2 + \frac{\sigma^2}{2}.

Here, the matrix A\mathbf{A} is Φ\mathbf{\Phi} and the scalar bb is σ22\frac{\sigma^2}{2}.

(3)

We have:

Eϵ[L(w^)]=σ22n.\mathbb{E}_{\mathbf{\epsilon}}[L(\mathbf{\hat{w}})] = \frac{\sigma^2}{2n}.

Thus:

Eϵ[L(w^)]Eϵ[L(w)]=12(w^w)TΦ(w^w)+σ22σ22n.\mathbb{E}_{\mathbf{\epsilon}}[L(\hat{\mathbf{w}})] - \mathbb{E}_{\mathbf{\epsilon}}[L(\mathbf{w^*})] = \frac{1}{2} (\hat{\mathbf{w}} - \mathbf{w}^*)^\mathbf{T} \mathbf{\Phi} (\hat{\mathbf{w}} - \mathbf{w}^*) + \frac{\sigma^2}{2} - \frac{\sigma^2}{2n}.

Therefore, the matrix B\mathbf{B} is Φ\mathbf{\Phi}.

(4)

When Φ\mathbf{\Phi} is not a regular matrix, it is singular and cannot be inverted. This usually happens when the features are linearly dependent, leading to multicollinearity. This makes the computation of w^\mathbf{\hat{w}} unstable or impossible.

A common remedy is to add a regularization term to the loss function, which is known as Ridge Regression. The modified loss function becomes:

L(w)=12nYXw22+λ2w22,L(\mathbf{w}) = \frac{1}{2n} \|\mathbf{Y} - \mathbf{Xw}\|_2^2 + \frac{\lambda}{2} \|\mathbf{w}\|_2^2,

where λ>0\lambda > 0 is a regularization parameter. The solution then becomes:

w^=(Φ+λI)1(1nXTY).\mathbf{\hat{w}} = (\mathbf{\Phi} + \lambda \mathbf{I})^{-1} \left( \frac{1}{n} \mathbf{X}^\mathbf{T} \mathbf{Y} \right).

Knowledge

机器学习 线性回归 最小二乘法 岭回归

解题技巧和信息

在回归问题中,当自变量之间存在共线性问题时,使用岭回归可以增加模型的稳定性并避免参数过大。理解最小二乘法的优化问题如何转化为矩阵求解问题是非常重要的。此外,加入正则化项可以有效地解决过拟合问题。

重点词汇

  • trace (迹) - 矩阵对角线元素之和
  • regular matrix (正规矩阵) - 具有满秩的矩阵,即矩阵的行列式非零
  • regularization (正则化) - 添加到损失函数的额外项,以约束模型复杂度并提高泛化能力

参考资料

  1. The Elements of Statistical Learning, Trevor Hastie, Robert Tibshirani, and Jerome Friedman, Chap. 3
  2. Pattern Recognition and Machine Learning, Christopher Bishop, Chap. 4