Coursera Machine Learning Week 3.2: Regularization

来源:互联网 发布:淘宝网食品流通许可证 编辑:程序博客网 时间:2024/06/05 06:10

这一节首先一开始就讲了bias,overfitting的问题。这个问题在statistical learning里也学到,在之前的文章《Cross validation的一点笔记》也有细说。


underfit, high bias 都是说这个model doesn't fit the data very well.

为了避免overfitting,有两种方法。


如果feature太多,而examples太少,就很容易导致overfitting,所以feature少一点比较好,挑有用的feature。

第二种方法表明,虽然feature少一点好,但是你不知道哪个feature有用,哪个feature没用,这个时候怎么办,就要用Regularization。(其实R语言里面用logistic regression的function来fit the model,然后summary一下也可以看哪些feature更相关一些)

所以接下来就引入Regularization的方法,这个方法很好理解。


这个例子可以看到,三次方和四次方其实是没用的,在J(西塔)的function中,在西塔三和西塔四前加上1000的系数,可以作为惩罚,这样最后minimize后其实得到的西塔三西塔四会很小,接近于零。


这就是修改后的J(西塔),右边多出来的部分就是regularization term,栏目大就是regularization parameter.

目标就是control the tradeoff between the two goals. 第一个goal 就是让前一部分fit the training set well,第二个goal就是为了让西塔系数相对small,栏目大的作用就是make it simple to avoid overfitting。



0 0
原创粉丝点击