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构建 ...
随机推荐
- [PA2014]Parking
[PA2014]Parking 题目大意: 停车场是一个宽度为\(w(w\le10^9)\)的矩形.我们以其左下角顶点为原点,坐标轴平行于矩形的边,建立直角坐标系.停车场很长,我们可以认为它一直向右边 ...
- GMA Round 1 数列与方程
传送门 数列与方程 首项为1,各项均大于0的数列{$a_n$}的前n项和$S_n$满足对于任意正整数n:$S_{n+1}^2-2*S_{n+1}*S_{n}-\sqrt{2}*S_n-1=0$,求$a ...
- 逆向工程-真码保存在系统文件破解QQ游戏对对碰助手
1)注册栏中输入任意值测试 1.2)记录弹出的关键字对话框 2.1)发送至PEID进行查壳 2.2)发现无壳 2.3)将软件载入OllyDBG程序 2.4)在反汇编栏下右键选择中文搜索引擎->智 ...
- map映射
采集于:https://blog.csdn.net/luanpeng825485697/article/details/78056312 映射map: var map = new Map(); //映 ...
- Python全栈-magedu-2018-笔记10
第三章 - Python 内置数据结构 集set 约定 set 翻译为集合 collection 翻译为集合类型,是一个大概念 set 可变的.无序的.不重复的元素的集合 set定义 初始化 set( ...
- Cassandra最小化安装
Cassandra最小化安装 环境 CentOS 7.2 64位 IP_address:172.27.0.8 安装包装备 [root@master ~]# ll /usr/local/src tota ...
- Mysql查询报错:Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='
使用sql别名关联查询的时候,由于字符集冲突导致该错误 解决方案,查询的时候强制转换字符集类型 case when column = '' then _gbk '' collate gbk_chine ...
- 汇编-13.0-int指令
1.int指令 int指令的格式为:int n,n为中断类型码,它的功能是引发中断过程. 执行int n指令,相当于引发一个中断号为n的中断过程. (1).取中断类型码n: (2).标志寄存器入栈,I ...
- webservice学习教程(二)--理论
一.WebService是什么? 1. 基于Web的服务:服务器端整出一些资源让客户端应用访问(获取数据) 2. 一个跨语言.跨平台的规范(抽象) 3. 多个跨平台.跨语言的应用间通信整合的方案(实际 ...
- 如何修改运行中的docker容器的端口映射和挂载目录
在docker run创建并运行容器的时候,可以通过-p指定端口映射规则.但是,我们经常会遇到刚开始忘记设置端口映射或者设置错了需要修改.当docker start运行容器后并没有提供一个-p选项或设 ...