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. 一点一点看JDK源码(二)java.util.List

    一点一点看JDK源码(二)java.util.List liuyuhang原创,未经允许进制转载 本文举例使用的是JDK8的API 目录:一点一点看JDK源码(〇) 1.综述 List译为表,一览表, ...

  2. Web—01-快速入门:HTML

    html概述和基本结构 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&qu ...

  3. Python 基础 变量和数据类型

    python 数据类型 一,整数,可以出来任意大小的整数. 如 1, 100, -8080,0 等等. 二,浮点数,浮点数也可以被成为小数. 三,字符串,字符串是以'' 或"". ...

  4. 竞赛题解 - [CF 1080D]Olya and magical square

    Olya and magical square - 竞赛题解 借鉴了一下神犇tly的博客QwQ(还是打一下广告) 终于弄懂了 Codeforces 传送门 『题目』(直接上翻译了) 给一个边长为 \( ...

  5. [异常笔记]启动DFS报错:Cannot find configuration directory: /etc/hadoop

    [hadoop@master ~]$ start-dfs.sh Incorrect configuration: namenode address dfs.namenode.servicerpc-ad ...

  6. python3 练习题100例 (五)

    题目五:输入三个整数x,y,z,请把这三个数由小到大输出. #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 题目五: ...

  7. C语言实例解析精粹学习笔记——18

    <C语言实例解析精粹>中编译环境采用的是Turbo C 2.0.但是这个编译器年代久远,较新的编译器对书中的某些例子支持不好,在学习的时候同时做一些笔记. 实例18:将一个无符号整数转换为 ...

  8. 4-c++教程起航篇-学习笔记

    c++教程起航篇 我们会讲C++那些事,C++与C语言的关系. C++诞生于贝尔实验室. C++之父: 本贾尼·斯特劳斯特卢普 C++社区排行榜 最新排行,c++排名第三,Python排名第四 C++ ...

  9. CakePHP Model中( 获取Session)使用Component的方法

    有时候我们需要在Model中使用Session,大家知道CakePHP把操作Session的方法封装为了一个Component, 在Model中正常读取Session的方法: 在 "app_ ...

  10. L010 linux命令及基础手把手实战总结

    一转眼都快两周没更新了,最近实在太忙了,这两周的时间断断续续的把L010学完了,短短的15节课,确是把前10节的课程全部的运用一遍,从笔记到整理,再到重新理解,最后发布到微博,也确实提升了一些综合性能 ...