In this page, I am going to talk about the 'hello world' model that is linear regression and train it with 2 different ways. one is the "closed-form" equation that directly computes the model parameters that best fit the model to the training set. This method is only ok to linear regression. The other one is the Gradient Descent method(GD), that gradually tweaks the model parameters to minimize the cost function over the training set, eventually converging to the same set of parameters as the first method.

Linear Regression

Below equation 1 is the linear regression model.

Below equation 2 is the vector/matrix equation

As talked before, we have the cost function is as below.  To train a model, we have to find the value of  to minimize the RMSE/MSE

The Normal Equation

Below is the "closed-form" solution to find the model parameters that minimize the cost function.

Directly calculate the parameters:

Make a predition of 2 test data and plot the data/model:

Using the sklearn lib to get the same thing:

Computational Complexity of Normal Equation

The Normal Equation computes the inverse of X.T.X, which is n*n matrix. It gets very slow when the number of features grows large(e.g., 100,000). Suggest to use it when n<=10000.

It is linear for the number of the training instances(m). The prediction is also linear with(n and m).  We will look at Gradient Descent in next article.

Training Models的更多相关文章

  1. 第四章——训练模型(Training Models)

    前几章在不知道原理的情况下,已经学会使用了多个机器学习模型机器算法.Scikit-Learn很方便,以至于隐藏了太多的实现细节. 知其然知其所以然是必要的,这有利于快速选择合适的模型.正确的训练算法. ...

  2. PDM:Training Models of Shape from Sets of Examples

    这篇论文介绍了一种创建柔性形状模型(Flexible Shape Models)的方法--点分布模型(Point Distribution Model).该方法使用一系列标记点来表示形状,重要的是根据 ...

  3. 壁虎书4 Training Models

    Linear Regression The Normal Equation Computational Complexity 线性回归模型与MSE. the normal equation: a cl ...

  4. ASM: Active Shape Models--Their Training and Application

    这篇论文的前半部分基本就是论文<Training Models of Shape from Sets of Examples>的全部内容,只不过多两个应用示例,后半部分在PDM模型的基础上 ...

  5. State of Hyperparameter Selection

    State of Hyperparameter Selection DANIEL SALTIEL VIEW NOTEBOOK Historically hyperparameter determina ...

  6. Classifying plankton with deep neural networks

    Classifying plankton with deep neural networks The National Data Science Bowl, a data science compet ...

  7. Microsoft AI - Custom Vision in C#

    概述 前面一篇 Microsoft AI - Custom Vision 中,我们介绍了 Azure 认知服务中的自定义影像服务:Custom Vision,也介绍了如果通过这个在线服务,可视化的完成 ...

  8. TensorFlow-Slim使用方法说明

    翻译自:https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/slim TensorFlow-Slim TF- ...

  9. TensorFlow 中文资源全集,官方网站,安装教程,入门教程,实战项目,学习路径。

    Awesome-TensorFlow-Chinese TensorFlow 中文资源全集,学习路径推荐: 官方网站,初步了解. 安装教程,安装之后跑起来. 入门教程,简单的模型学习和运行. 实战项目, ...

随机推荐

  1. asp.net mvc5 step by step(三)—— Entity Framework Database First

    一.先建数据库. 打开,SQL Server Management 新建数据库Employee 并新建表 /****** Object: Table [dbo].[t_Employee] Script ...

  2. UCanCode发布升级E-Form++可视化源码组件库2018全新版 !

    2018年. 成都 UCanCode发布升级E-Form++可视化源码组件库2018全新版 ! --- 全面性能提升,UCanCode有史以来最强大的版本发布! E-Form++可视化源码组件库企业版 ...

  3. Django学习笔记5-url

    先来看一下普通的url的格式 {% url 'login_action'%} 但由于name没有作用域,Django在反解URL时,会在项目全局顺序搜索,当查找到第一个name指定URL时,立即返回 ...

  4. Java线程状态图

    嘤,先盗图一张,后面再补充描述!

  5. python 解积分方程

    引用:https://www.aliyun.com/jiaocheng/527786.html sympy求解极限.积分.微分.二元一次方程:http://www.gzhshoulu.wang/art ...

  6. Python学习3——变量如何存储数据

    数值类型:包括整型.浮点型 变量名字代表的是存储地址. num01 = 100 print(id(num01)) #输出变量num01存储的内存地址,输出的是十进制值 num02 = num01 pr ...

  7. 1010 一元多项式求导 (25 分) C语言

    设计函数求一元多项式的导数.(注:x​n​​(n为整数)的一阶导数为nx​n−1​​.) 输入格式: 以指数递降方式输入多项式非零项系数和指数(绝对值均为不超过 1000 的整数).数字间以空格分隔. ...

  8. HyperLedger Fabric 1.4 kafka生产环境部署(11.1)

    11.1 Kafka模式简介       上一章介绍的Solo模式只存在一个排序(orderer)服务,是一种中心化结构,一旦排序(orderer)服务出现了问题,整个区块链网络将会崩溃,为了能在正式 ...

  9. ACM数论-欧几里得与拓展欧几里得

    ACM数论——欧几里得与拓展欧几里得 欧几里得算法: 欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数. 基本算法:设a=qb+r,其中a,b,q,r都是整数,则gcd(a,b)=gcd ...

  10. Hibernate学习笔记一

    1 框架体系结构 2 hibernate入门 2.1 ORM框架 Hibernate是一个数据持久化层的ORM框架. Object:对象,java对象,此处特指JavaBean Relational: ...