Skip to content

Commit

Permalink
week6
Browse files Browse the repository at this point in the history
  • Loading branch information
marssurface committed Nov 2, 2017
1 parent 92aac32 commit 4cd22f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions week6.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ x3等等。也许有很多特征,也许你可以花一点时间从这些特征
​ 测试集评估在通过训练集让我们的模型学习得出其参数后,对测试集运用该模型,我们有两种方式计算误差:

1. 对于线性回归模型,我们利用测试集数据计算代价函数J

2. 对于逻辑回归模型,我们除了可以利用测试数据集来计算代价函数外:

![](media/27c368daeed61b7bba15ccdbbb227be9.png)
$$ J_{test}{(\theta)} = -\frac{1}{{m}_{test}}\sum_\limits{i=1}^{m_{test}}\log{h_{\theta}\left(x^{(i)}_{test}\right)}+\left(1-{y^{(i)}_{test}}\right)\log{h_{\theta}\left(x^{(i)}_{test}\right)}$$

> 误分类的比率,对于每一个测试集实例,计算:
> 误分类的比率,对于每一个测试集实例,计算:
![](media/751e868bebf4c0bf139db173d25e8ec4.png)

Expand Down Expand Up @@ -91,7 +90,19 @@ x3等等。也许有很多特征,也许你可以花一点时间从这些特征

4. 用步骤3中选出的模型对测试集计算得出推广误差(代价函数的值)

![](media/9aa321e095958ece7b9b920a1b9e0be6.png)
***Train/validation/test error***

*Training error:*

$$J_{train}\left(\theta\right) = \frac{1}{2m}\sum_\limits{i=1}^{m}\left(h_{\theta}\left(x^{(i)}\right)-y^{(i)}\right)^2$$

*Cross Validation error:*

$$J_{cv}\left(\theta\right) = \frac{1}{2m_{cv}}\sum_\limits{i=1}^{m}\left(h_{\theta}\left(x^{(i)}_{cv}\right)-y^{(i)}_{cv}\right)^2$$

*Test error:*

$$J_{test}\left(\theta\right)=\frac{1}{2m_{test}}\sum_\limits{i=1}^{m_{test}}\left(h_{\theta}\left(x^{(i)}_{cv}\right)-y^{(i)}_{cv}\right)^2$$

### 10.4 诊断偏差和方差

Expand Down
2 changes: 1 addition & 1 deletion week7.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

如果 C非常大,则最小化代价函数的时候,我们将会很希望找到一个使第一项为0的最优解。因此,让我们尝试在代价项的第一项为0的情形下理解该优化问题。比如我们可以把C设置成了非常大的常数,这将给我们一些关于支持向量机模型的直观感受。

![](media/1f434cdbd936c6953c0c8053b9126075.png)
$$\min_\limits{\theta}C\sum_\limits{i=1}^{m}\left[y^{(i)}{\cos}t_{1}\left(\theta^{T}x^{(i)}\right)+\left(1-y^{(i)}\right){\cos}t\left(\theta^{T}x^{(i)}\right)\right]+\frac{1}{2}\sum_\limits{i=1}^{n}\theta^{2}_{j}$$

我们已经看到输入一个训练样本标签为y=1,你想令第一项为0,你需要做的是找到一个θ,使得$\theta^Tx$\>=1,类似地,对于一个训练样本,标签为y=0,为了使${\cos}t_0{(z)}$ 函数的值为0,我们需要$\theta^Tx$<=-1。因此,现在考虑我们的优化问题。选择参数,使得第一项等于0,就会导致下面的优化问题,因为我们将选择参数使第一项为0,因此这个函数的第一项为0,因此是C乘以0加上二分之一乘以第二项。这里第一项是C乘以0,因此可以将其删去,因为我知道它是0。

Expand Down

0 comments on commit 4cd22f3

Please sign in to comment.