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构建 ...
随机推荐
- NEERC-2017
A. Archery Tournament 用线段树套set维护横坐标区间内的所有圆,查询时在$O(\log n)$个set中二分查找即可. 时间复杂度$O(n\log^2n)$. #include& ...
- CSS3常用
1.user-select新增特性,主流浏览器都支持 -webkit-user-select: none; /* Chrome all / Safari all /opera15+*/ -moz- ...
- __x__(8)0906第三天__乱码问题
需要知道: 计算机只认 0 1 任何内容,计算机都会以 0 1 去存储 所以 0 1 与内容的编码方式/解码方式需要依照一定的规则,实现 0 1 与内容之间的转换. 字符集:一定的规则,由编码/解码采 ...
- Promise 用法
Promise是一个构造函数,自己身上有all.reject.resolve这几个眼熟的方法,原型上有then.catch等同样很眼熟的方法. 那就new一个 Promise的构造函数接收一个参数,是 ...
- element-ui中上传文件upload
<el-upload class="upload-demo" name="targetFile" ref="upload" :with ...
- 熟悉Linux常用命令
cd命令:切换目录 (1)切换到目录 /usr/localcd / usrcd / local (2)去到目前的上层目录cd .. (3)回到自己的主文件夹cd ls命令:查看文件与目录 (4)查看目 ...
- java_爬虫_从腾讯视频播放界面爬取视频真实地址
由于想在微信公众号里爬一点儿考研的视频 花了差不多一天的时间把这个爬虫做好(其实也不算爬虫吧,就算个能批量处理的地址解析器,半个爬虫) 不多说,进正题 (本文适合有java基础的同学,没基础的用客户端 ...
- C#中$的用法
class Program { static void Main(string[] args) { string tbName = "User"; string colName = ...
- ZD6转辙机
1.转辙机的分类? 2.ZD6转辙机的电源电压是多少? 3.ZD6转辙机的电路图是怎么样的? 经常看到的一些术语: DBJ,FBJ DCJ FCJ DBJ 定位表示继电器 FBJ 反位表示继电器 DC ...
- numpy/pandas时间互相转换
一图看懂互相转换: