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构建 ...
随机推荐
- sql测验,like 和 = 的区别
.SQL 指的是? 您的回答:Structured Query Language .哪个 SQL 语句用于从数据库中提取数据? 您的回答:SELECT .哪条 SQL 语句用于更新数据库中的数据? 您 ...
- LeetCode第二题
题目描述: You are given two non-empty linked lists representing two non-negative integers. The digits ar ...
- ie下js不执行的几种可能
1.首先考虑的就是代码是否有报错2.其次搜索代码中是否有console.log等测试的代码3.检查所用的方法是否兼容ie 以上是鄙人在开发过程中遇到的几种情况,抛砖来引玉~~
- Node.js_express_浏览器存储技术 Cookie(服务器将少量数据交于浏览器存储管理)
浏览器存储技术 Cookie 服务器将少量数据交于浏览器存储管理 解决 http 无状态协议的问题(无法区分多次请求是否发送自同一客户端) 一个网页一般最多 20个的 cookie,每个 cookie ...
- Retrieve pictures from Excel file using OLEDB
string file = @"C:\sample.xlsx"; if(System.IO.File.Exists(file)) { Microsoft.Office.Intero ...
- 字符串Hash || BZOJ 3555: [Ctsc2014]企鹅QQ || P4503 [CTSC2014]企鹅QQ
题面:[CTSC2014]企鹅QQ 题解:无 代码: #include<iostream> #include<cstring> #include<cstdio> # ...
- DocX Xceed.Words.NET操作Word,插入特殊符号
x 传送门,我们走... DocX的Github传送门 介绍一 介绍二 写入特殊符号 开始... 自己做一个工具,要导出Word的,当时刚开始想使用Xceed.Words.NET.dll第三方插件进行 ...
- MyCP-实现文件的复制以及进制转换
MyCP 一.设计思路 确定MyCP的要求 根据需求可知MyCP需要实现类似Linux下cp XXX1 XXX2的功能,且需要支持两个参数: java MyCP -tx XXX1.txt XXX2.b ...
- python连接服务器上传文件,后台执行命令
上传文件 import os import paramikoimport logging from django.core.cache import cache from YunTai import ...
- Troubleshooting tips for using Java on Windows 8
This article applies to: Platform(s): Windows 8 Will Java run in Start screen on Windows 8? Microsof ...