Machine Learning Andrew Ng -4. Linear Regression with multiple variables

4.1 Multiple features (多特征量)

Multiple features (variables)

Size ( x 1 ) (x_1) Number of bedrooms ( x 2 ) (x_2) Number of floors ( x 3 ) (x_3) Age of homes ( x 4 ) (x_4) Price ( y ) (y)
2104 5 1 45 460
1416 3 2 40 232
1534 3 2 30 315
852 2 1 36 178

Notation :

  • n n = number of features
  • x ( i ) x^{(i)} = input (features) of i t h i^{th} training example
  • x j ( i ) x_j^{(i)} = value of feature j j in i t h i^{th} training example

Hypothesis :

previously : h θ ( x ) = θ 0 + θ 1 x h_{\theta}(x) = \theta_0 + \theta_1x

now : h θ ( x ) = θ 0 + θ 1 x 1 + θ 2 x 2 + θ 3 x 3 + θ 4 x 4 h_{\theta}(x) = \theta_0+\theta_1x_1+\theta_2x_2+\theta_3x_3+\theta_4x_4

在这里插入图片描述

Multivariate linear regression 多元线性回归

4.2 Gradient descent for multiple variables

How to fit the parameters of that hypothesis ? How to use gradient descent for linear regression with multiple features ?

在这里插入图片描述

在这里插入图片描述

4.3 Gradient descent in practice I : Feature Scaling(特征缩放)

在这里插入图片描述

Feature Scaling : Get every feature into approximately a 1 x i 1 -1 \leqslant x_i\leqslant 1 range.

Mean normalization (均值归一化) :

在这里插入图片描述

4.4 Gradient descent in practice II : Learning rate

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

4.5 Features and polynomial regression (特征和多项式回归)

Choosing feature

在这里插入图片描述

The price could be a quadratic function (二次函数), or a cubic function (三次函数)

在这里插入图片描述

now feature scaling is more important

在这里插入图片描述
How to choose features ? Discuss later…

4.6 Normal equation (正规方程)

Normal equation : Method to solve for θ \theta analytically.

One step, you get to the optimal value right there.

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

这里X矩阵上下标大概率写错了

在这里插入图片描述

Feature Scaling is no need

When choose gradient descent when choose normal equation ?

在这里插入图片描述

4.7 Normal equation and non-invertibility

在这里插入图片描述
在这里插入图片描述

发布了44 篇原创文章 · 获赞 0 · 访问量 1350

猜你喜欢

转载自blog.csdn.net/qq_41664688/article/details/104016468