多变量线性回归
Multiple features (variables)
Size x1 |
Number of bedrooms x2 |
Number of floors x3 |
Age of home(year) x4 |
Price y |
2014 | 5 | 1 | 45 | 460 |
1416 | 3 | 2 | 40 | 232 |
1534 | 3 | 2 | 30 | 315 |
852 | 2 | 1 | 36 | 178 |
Notation:
n = number of features
x(i) = input (features) of ith training example.
\[x_j^{\left( i \right)}\] value of feature j in ith training example.
符号
n = 特征的数量
x(i) = 第i个训练样本
\[x_j^{\left( i \right)}\] 第i个样本的第j个特征
举例
x(2) = [1416
3
2
40]
\[x_3^2 = 2\]
线性回归中的hθ(x)不再是 \[{h_\theta }\left( x \right) = {\theta _0} + {\theta _1}x\]
而是 \[{h_\theta }\left( x \right) = {\theta _0} + {\theta _1}{x_1} + {\theta _2}{x_2} + ... + {\theta _n}{x_n}\]
为了方便起见,我们定义x0 = 1,也就是 \[x_0^i = 1\]
x = [x0 θ = [θ1
x1 θ2
. .
. .
xn] θn]
则 \[{h_\theta }\left( x \right) = {\theta ^T}x\]