[ 机器学习 - 吴恩达 ] 单变量线性回归 | 2-2 损失函数 1
房价训练集(俄勒冈州,波特兰市)
Size in \(feet^2\) (x) | Price ($) in 1000's (y) |
---|---|
2104 | 460 |
1416 | 232 |
1534 | 315 |
852 | 178 |
假设函数: \(h_\theta(x) = \theta_0 + \theta_1x\)
参数:\(\theta_{i's}\)
如何选择 \(\theta_{i's}\)?
想法:对于我们的训练样例 \((x, y)\),选择\(\theta_0, \theta_1\),使\(h_\theta(x)\)靠近\(y\)
Cost Function 损失函数
\[J(\theta_0,\theta_1) = 1/2m\sum_{i=1}^m(h_\theta(x^{(i)}) - y^{(i)})^2 \]m:训练样本数
总结
假设函数
\[h_\theta(x) = \theta_0 + \theta_1x \]参数: \(\theta_0, \theta_1\)
损失函数: 均方误差函数(Squared error function)**
目标: \(\begin{matrix} minimize J(\theta_0,\theta_1)\\ \theta_0,\theta_1 \end{matrix}\)
简化:
假设函数:
\[h_\theta(x) = \theta_1x \]参数: \(\theta_1\)
损失函数:
目标: \(\begin{matrix} minimize J(\theta_1)\\ \theta_1 \end{matrix}\)