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. Web版记账本开发记录(一)代码和功能展示

    一丶基本机构 数据库截图 record表 年份表 index.jsp <%@ page language="java" contentType="text/html ...

  2. 全排列筛选(java)

    蓝桥杯-全排列筛选(java) 蓝桥杯每年必考全排列筛选,一般为填空题: 可以使用for循环暴力破解,但是代码相对较长,也比较乱,不建议使用: 这里使用递归来解决,代码量相对较少,也很好理解: 如下为 ...

  3. 输入正整数n,求各位数字和

    import java.util.Scanner; /** * @author:(LiberHome) * @date:Created in 2019/3/5 10:24 * @description ...

  4. solr 入门

    这个博客写的不错,很详细 https://blog.csdn.net/wzy18210825916/article/details/80946454

  5. 对于EMC DAE、DPE、SPE、SPS的解释

    对于EMC DAE.DPE.SPE.SPS的解释: DAE: Disk Array Enclosure 单一的磁盘扩展单元 CX200/CX300/CX400/CX500CX600/CX700 DPE ...

  6. 总结-shell脚本

    执行脚本从 svn 检出项目 vi ace.sh #!/bin/bash svn export svn://127.0.0.1/ace/demo /ace/demo 设置脚本可执行 chmod +x ...

  7. Python全栈-magedu-2018-笔记10

    第三章 - Python 内置数据结构 集set 约定 set 翻译为集合 collection 翻译为集合类型,是一个大概念 set 可变的.无序的.不重复的元素的集合 set定义 初始化 set( ...

  8. 【Python基础】lpthw - Exercise 41 学习面向对象术语

    一.专有词汇 类(class):告诉python创建新类型的东西. 对象(object):两个意思,即最基本的东西,或者某样东西的实例. 实例(instance):让python创建一个类时得到的东西 ...

  9. Luogu5155 [USACO18DEC]Balance Beam

    题目链接:洛谷 这道题看起来是个期望题,但是其实是一道计算几何(这种题太妙了) 首先有一个很好的结论,在一个长度为$L$的数轴上,每次从$x$处出发,不停地走,有$\frac{x}{L}$的概率从右端 ...

  10. centos7中安装mysql5.6版本 + 主从复制

    centos安装5.6版本:CentOS7下使用YUM安装MySQL5.6 主从复制:Mysql主从复制与读写分离原理及配置教程 主从复制问题及配置 卸载和安装5.7版本:CentOS 7 安装与卸载 ...