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 第三周的更多相关文章

  1. Hand on Machine Learning第三章课后作业(1):垃圾邮件分类

    import os import email import email.policy 1. 读取邮件数据 SPAM_PATH = os.path.join( "E:\\3.Study\\机器 ...

  2. 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 ...

  3. Machine Learning - 第3周(Logistic Regression、Regularization)

    Logistic regression is a method for classifying data into discrete outcomes. For example, we might u ...

  4. Machine Learning第十一周笔记:photo OCR

    博客已经迁移至Marcovaldo's blog (http://marcovaldong.github.io/) 刚刚完毕了Cousera上Machine Learning的最后一周课程.这周介绍了 ...

  5. 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 ...

  6. Machine Learning 第一二周

    # ML week 1 2 一.关于machine learning的名词 学习 从无数数据提供的E:experience中找到一个函数使得得到T:task后能够得到P:prediction 监督学习 ...

  7. Machine Learning第十周笔记:大规模机器学习

    博客已经迁移到Marcovaldo's blog (http://marcovaldong.github.io/) 刚刚完毕了Andrew Ng在Cousera上的Machine Learning的第 ...

  8. 吴恩达《深度学习》-第一门课 (Neural Networks and Deep Learning)-第三周:浅层神经网络(Shallow neural networks) -课程笔记

    第三周:浅层神经网络(Shallow neural networks) 3.1 神经网络概述(Neural Network Overview) 使用符号$ ^{[

  9. Machine Learning - 第7周(Support Vector Machines)

    SVMs are considered by many to be the most powerful 'black box' learning algorithm, and by posing构建 ...

随机推荐

  1. oracle直接读写ms sqlserver数据库(一)如何下载oracle database gateway for sqlserver

    想从Oracle实时同步数据到Ms Sqlserver,需要在Oracle里面直连Sqlserver进行数据的读写,可以在Oracle服务器上安装oracle database gateway for ...

  2. CSS(五)

    定位 关于定位 我们可以使用css的position属性来设置元素的定位类型,postion的设置项如下: relative 生成相对定位元素,元素所占据的文档流的位置不变,元素本身相对文档流的位置进 ...

  3. 树形数组 java

    2^k求法 int lowbit(int x) { return x&(-x); } lowbit()的返回值就是 2^k 次方的值. 基本树形数组的模板 import java.util.* ...

  4. React(四)组件生命周期

    组件的生命周期可分成三个状态: Mounting:已插入真实 DOM Updating:正在被重新渲染 Unmounting:已移出真实 DOM 生命周期的方法有: componentWillMoun ...

  5. 【欧拉回路+最小生成树】SD开车@山东2018省队一轮集训day1

    目录 [欧拉回路+最小生成树]SD开车@山东2018省队一轮集训day1 PROBLEM 题目描述 输入 输出 样例输入 样例输出 提示 SOLUTION CODE [欧拉回路+最小生成树]SD开车@ ...

  6. phpMyAdmin 4.8.x 本地文件包含漏洞利用

    phpMyAdmin 4.8.x 本地文件包含漏洞利用 今天ChaMd5安全团队公开了一个phpMyAdmin最新版中的本地文件包含漏洞:phpmyadmin4.8.1后台getshell.该漏洞利用 ...

  7. SQL2005EXPress自动备份

    STEP1:在数据库服务器的master表中创建存储过程sp_BackupDatabase 代码如下 USE [master] GO /****** 对象: StoredProcedure [dbo] ...

  8. UIAlertController中TextField的用法

    这时候可以添加如下代码: [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) { // 可以 ...

  9. SET || BZOJ 1588: [HNOI2002]营业额统计 || Luogu P2234 [HNOI2002]营业额统计

    题面:P2234 [HNOI2002]营业额统计 题解:随便写写 注意:cmath中abs函数返回的是一个浮点数,在bzoj上会ce 代码: #include<cstdio> #inclu ...

  10. django分页

    page_count = 1 current_page = int(request.GET.get('p',1)) course1 = Course.objects.all().order_by('- ...