Machine Learning - week 3 - Overfitting

The Problem of Overfitting

如果有太多的 features,假设可能与训练数据太匹配了以致于预测未来的数据不准确。如下图:

解决 overfitting

1. 既然是由太多的 features 引起的,那么就排除一些 features

2. Regularization

不变动 features,因为 features 也是带有信息的,但是减少 θj 的数量级

Regularization Cost Function

Regularization

各个 θ 的参数越小,那么 h(θ) 会越简单,更不会 overfitting;

λ 叫做 regularization parameter,用来调节 regularization。注意,这里 j 是从 1 开始,所以 θ0 不需要包括进来。

如果 λ 很小,那我就当它为 0,会造成 overfitting;

如果 λ 很大,那么 θ 就会接近 0,然后是一条直线(θ0),造成 underfitting。

Regularized Linear Regression

J(θ)

只需要在 α 中加上 (θj / m ) * λ

Gradient descent

化简后,为

,因为 1 - αλ/m < 1,所以 θ 是一直减小的。

对 Normal Equation 使用,公式如下

Regularized Logistic Regression

J(θ)

与上方的一样,加上,在 α 中加上 (θj / m ) * λ,变成

Gradient Descent

与上方的一样。

所以这里与上面是一样的,只是 h(θ) 不同。

Advanced optimization

与之前一样。计算 J(θ) 、gradient 的方程,这里替换过去就可以。

时间: 2024-08-08 09:29:33

Machine Learning - week 3 - Overfitting的相关文章

CMT307 Applied Machine Learning

Cardiff School of Computer Science and InformaticsCoursework Assessment Pro-formaModule Code: CMT307Module Title: Applied Machine LearningAssessment Title: Coursework 1Assessment Number: 1Date Set: Monday, October 28thSubmission Date and Time: Tuesda

New to Machine Learning? Avoid these three mistakes

http://blog.csdn.net/pipisorry/article/details/43973171 James Faghmous提醒机器学习初学者要避免的三方面错误,推荐阅读 New to Machine Learning? Avoid these three mistakes Common pitfalls when learning from data Machine learning (ML) is one of the hottest fields in data scien

NTU-Coursera机器学习:机器学习基石 (Machine Learning Foundations)

课讲内容 这门课以8周设计,分成 4个核心问题,每个核心问题约需2周的时间来探讨.每个约2个小时的录影中,每个小时为一个主题,以会各分成4到5个小段落,每个段落里会有一个后多个随堂的练习.我们在探讨每个核心问题的第二周.依上所述,課程的規畫如下: When Can Machines Learn? [何时可以使用机器学习] 第一周:(NTU-Coursera机器学习:机器学习问题与二元分类) 第一讲:The Learning Problem [机器学习问题]第二讲:Learning to Answ

【转载】COMMON PITFALLS IN MACHINE LEARNING

COMMON PITFALLS IN MACHINE LEARNING JANUARY 6, 2015 DN 3 COMMENTS Over the past few years I have worked on numerous different machine learning problems. Along the way I have fallen foul of many sometimes subtle and sometimes not so subtle pitfalls wh

【coursera笔记】Machine Learning(Week6)

发现自己不写总结真是件很恶劣的事情,好多学的东西没有自己总结都忘记了.所以决定从今天开始,学东西的时候一定跟上总结. 我写的东西大多数是自己通俗的总结,不太喜欢写严格的定义或者证明,写了也记不住,欢迎指正. 1. High Bias vs. High Variance High Bias:通常是因为模型过于简单,使得不能成功拟合数据.比如说一些有二次曲线特性的数据,如果用一次直线去拟合就会出现这个问题,所以它对应了Underfitting问题.另外,从泛化角度来说,这样的模型泛化程度更高. Hi

Getting started with machine learning in Python

Getting started with machine learning in Python Machine learning is a field that uses algorithms to learn from data and make predictions. Practically, this means that we can feed data into an algorithm, and use it to make predictions about what might

Brief History of Machine Learning

Brief History of Machine Learning My subjective ML timeline Since the initial standpoint of science, technology and AI, scientists following Blaise Pascal and Von Leibniz ponder about a machine that is intellectually capable as much as humans. Famous

Andrew Ng Machine Learning - Week 3:Logistic Regression &amp; Regularization

此文是斯坦福大学,机器学习界 superstar - Andrew Ng 所开设的 Coursera 课程:Machine Learning 的课程笔记.力求简洁,仅代表本人观点,不足之处希望大家探讨. 课程网址:https://www.coursera.org/learn/machine-learning/home/welcome Week 1: Introduction 笔记:http://blog.csdn.net/ironyoung/article/details/46845233 We

Decision Boundaries for Deep Learning and other Machine Learning classifiers

Decision Boundaries for Deep Learning and other Machine Learning classifiers H2O, one of the leading deep learning framework in python, is now available in R. We will show how to get started with H2O, its working, plotting of decision boundaries and