文章目录
multiple linear regression多元线性回归
1. 多维特征 Multiple features
- xj = 第j个feature
- n = feature的个数
- x ⃗^(i) = 第(i)个training example的features。(行向量row vector)
- (x_j ) ⃗^(i) = 第(i)个training example的第j个feature的值。
如: x_3^2 = 第3个training example的第2个feature = 3
- model:
- w ⃗ = [w1, w2, …wn] 是parameter of the model
- b 是一个常数
- x ⃗ = [x1, x2, x3, … xn]
- multiple linear regression(不是multivariate regression)
2. 向量化 vectorization
- 不使用dot product一个一个乘积相加,如果n很大的时候,非常耗时。
- 不实用dot product,使用for loop可以提升效率,但还不够
- dot product会提升代码效率,只需要一行。
f = np.dot(w,x) + b
- 是否使用vectorization的效率差别:
3. 多元线性回归的梯度下降
- notation的不同:
4. normal equation正规方程
- 定义:
(1)只适用于linear regression
(2)不需要iterations,解决w,b的值。 - 缺点:
(1)这个在其他算法不适用。
(2)会很慢,如果features很大(n > 10,000) - 有些机器学习库会在后端back-end解决w和b。
- 对于找到parameter w和b的问题,还是推荐使用gradient descent梯度下降。