多重回归
之前我们是根据广告费来预测点击量,但是在实际中可能要解决的很多问题是变量超过两个的复杂问题。我们收集的数据中不仅包括了广告费,还有其它的信息,比如广告的展示位置和广告版面的大小等多个要素,现在我们要用这些要素来预测点击量。
f_{\theta}(x_1, x_2, x_3) = \theta_0+\theta_1x_1 + \theta_2x_2 + \theta_3x_3
f_{\theta}(x_1, \cdots, x_n) = \theta_0 + \theta_1x_1 + \cdots +\theta_nx_n
f_{\theta}(x_1, \cdots, x_n) = \theta_0x_1 + \theta_1x_1 + \cdots +\theta_nx_n
{\theta} =
\begin{bmatrix}
\theta_0 \\
\theta_1 \\
\theta_2 \\
\vdots \\
\theta_n
\end{bmatrix} \ \ \ \ \ \ \ \ \
{x} =
\begin{bmatrix}
x_0 \\
x_1 \\
x_2 \\
\vdots \\
x_n
\end{bmatrix} (x_0 = 1)
f_{\theta}({x}) = {\theta}^{T}{x}
\frac{\partial E}{\partial \theta_j} = \frac{\partial E}{\partial f_{\theta}(x)}\frac{\partial f_{\theta}(x)}{\partial\theta_j}
其中
\frac{\partial E}{\partial f_{\theta}(x)} 在学习回归 1-3 梯度下降法已经计算过了,现在只需要计算
\frac{\partial f_{\theta}(x)}{\partial\theta_j}。
\begin{split}
\frac{\partial f_{\theta}(x)}{\partial\theta_j} &= \frac{\partial}{\partial\theta_j}({\theta}^{T}{x})\\
&=\frac{\partial}{\partial\theta_j}(\theta_0x_1 + \theta_1x_1 + \cdots +\theta_nx_n) \\
&= x_j
\end{split}
第
j 个参数的梯度下降算法的更新表达式如下:
\theta_j := \theta_j - \eta\sum_{i = 1}^{n}(f_{\theta}(x^{(i)}) - y^{(i)})x_j^{(i)}
至此,我们将每个参数的梯度下降算法的更新表达式汇总成一个通用的表达式。
References:
《白话机器学习的数学》