Machine Learning 第三周
ML week3 逻辑回归
Logistic Function
h_\theta(x)=g(\theta^Tx)
g(t)=\frac{1}{1+e^{-z}}

当t大于0, 即下面公式成立时,y=1
\frac{1}{1+e^{-{\theta^Tx}}}>0.5 => {\theta^Tx}>0
关于theta与数据
y(x)=\theta_0+\theta_1x1+\theta_2x2
y(x)=\theta_0+\theta_1x_1+\theta_2x_2+\theta_3 x_1^2+\theta_4x_1x_2+\theta_5x_2^2
Cost function
由于使用线性回归的cost function会产生波浪形而达不到global最优点,所以使用新的方程
Cost(h_\theta(x),y) = -ylog(h_\theta(x))-(1-y)log(h_\theta(x))
多项式形式


矩阵形式

梯度下降算法

矩阵形式

使用其他更快的算法
function [jVal, gradient] = costFunction(theta)
jVal = [...code to compute J(theta)...];
gradient = [...code to compute derivative of J(theta)...];
end
options = optimset('GradObj', 'on', 'MaxIter', 100);
initialTheta = zeros(2,1);
[optTheta, functionVal, exitFlag] = fminunc(@costFunction, initialTheta, options);
当y不止0,1时
如:天气有cloudy rainy sunny

问题:画出的线重复怎么办

过拟合


1)减少的特征:
- 手动选择特征来保持。
- 使用模型选择算法进行。(介绍 )
2)正规化
- 保持所有的特征,但减小的幅度的参数θJ。
- 正则化时,我们有许多稍微有益的特征
梯度下降防止过拟合
改变cost function

而梯度下降会变为

正规方程防止过拟合

Machine Learning 第三周的更多相关文章
- Hand on Machine Learning第三章课后作业(1):垃圾邮件分类
import os import email import email.policy 1. 读取邮件数据 SPAM_PATH = os.path.join( "E:\\3.Study\\机器 ...
- Machine Learning - 第6周(Advice for Applying Machine Learning、Machine Learning System Design)
In Week 6, you will be learning about systematically improving your learning algorithm. The videos f ...
- Machine Learning - 第3周(Logistic Regression、Regularization)
Logistic regression is a method for classifying data into discrete outcomes. For example, we might u ...
- Machine Learning第十一周笔记:photo OCR
博客已经迁移至Marcovaldo's blog (http://marcovaldong.github.io/) 刚刚完毕了Cousera上Machine Learning的最后一周课程.这周介绍了 ...
- Machine Learning – 第2周(Linear Regression with Multiple Variables、Octave/Matlab Tutorial)
Machine Learning – Coursera Octave for Microsoft Windows GNU Octave官网 GNU Octave帮助文档 (有900页的pdf版本) O ...
- Machine Learning 第一二周
# ML week 1 2 一.关于machine learning的名词 学习 从无数数据提供的E:experience中找到一个函数使得得到T:task后能够得到P:prediction 监督学习 ...
- Machine Learning第十周笔记:大规模机器学习
博客已经迁移到Marcovaldo's blog (http://marcovaldong.github.io/) 刚刚完毕了Andrew Ng在Cousera上的Machine Learning的第 ...
- 吴恩达《深度学习》-第一门课 (Neural Networks and Deep Learning)-第三周:浅层神经网络(Shallow neural networks) -课程笔记
第三周:浅层神经网络(Shallow neural networks) 3.1 神经网络概述(Neural Network Overview) 使用符号$ ^{[
- Machine Learning - 第7周(Support Vector Machines)
SVMs are considered by many to be the most powerful 'black box' learning algorithm, and by posing构建 ...
随机推荐
- dagger2 依赖注入
前言: 当 mvp + dagger2 + rxjava 三者遇上,架构更加清晰,代码更加灵活,巧妙结合. 依赖注入:是为了解耦,达到高内聚低耦合的目的,保证代码的健壮性.灵活性和可维护性. publ ...
- __x__(20)0907第四天__列表ul,ol,dl
列表分为: 有序列表 ul: <ul type="disc"> <li>张三</li> <li>李四</li> < ...
- Jmeter应用-接口测试
1.BS架构应用性能 2.HTTP协议接口功能与性能 3.FTP协议接口功能与性能 4.Mysql数据库性能 5.MongoDB数据库性能 6.支持自定义Java组件开发 测试计划-右键-添加线程组 ...
- Python练手例子(8)
43.模仿静态变量(static)另一案例. 程序分析:演示一个python作用域使用方法. #python3.7 class Num: nNum = 1 def inc(self): self.nN ...
- 如何使用iOS开发者授权以及如何申请证书
如何使用iOS开发者授权以及如何申请证书 在邮件里有一个Login按钮,点击后可以进入Apple Developer会员中心.点击图中的iOS Provisioning Portal,进入开发者授权设 ...
- DevExpress控件GridControl中的布局详解 【转】
DevExpress控件GridControl中的布局详解 [转] 2012-10-24 13:27:28| 分类: devexpress | 标签:devexpress |举报|字号 订阅 ...
- c++ 库函数cmath
cmath中常用库函数: int abs(int i);//返回整型参数i的绝对值double fabs(double x);//返回双精度参数x的绝对值long labs(long n);//返回长 ...
- Multi-Projector Based Display Code ---- ImageViewer
Overview Image viewer is a typical application for large display. It makes use of the high-resolutio ...
- 刷榜中ASO优化中下载量与评论之间的对应比
刷榜中ASO优化中下载量与评论之间是怎么样对应,我们都知道,在ASO优化的过程中,ASO优化师在做下载量后的二至三天,都会顺带着做一下评论.这时候问题就来了,下载量与评论的比例关系应该如何确定呢?最近 ...
- 用jieba库统计文本词频及云词图的生成
一.安装jieba库 :\>pip install jieba #或者 pip3 install jieba 二.jieba库解析 jieba库主要提供提供分词功能,可以辅助自定义分词词典. j ...