博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Training Models
阅读量:5238 次
发布时间:2019-06-14

本文共 1448 字,大约阅读时间需要 4 分钟。

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.

 

转载于:https://www.cnblogs.com/nativestack/p/ml_train_linear.html

你可能感兴趣的文章
JavaScript可否多线程? 深入理解JavaScript定时机制
查看>>
IOS基础学习
查看>>
PHP 导出 Excell
查看>>
Java基础教程——网络基础知识
查看>>
自己到底要的是什么
查看>>
Kruskal基础最小生成树
查看>>
ubuntu 14.04 安装搜狗拼音输入法
查看>>
浅谈算法和数据结构: 一 栈和队列
查看>>
Java内部类详解
查看>>
【hdu 1429】胜利大逃亡(续)
查看>>
图论-次短路求法
查看>>
What's New for Visual C# 6.0
查看>>
ExtJs学习笔记之ComboBox组件
查看>>
关于收费软件
查看>>
getopt_long
查看>>
TensorFlow MNIST CNN 代码
查看>>
javascript之Style物
查看>>
JSON跨域解决方案收集
查看>>
SSH框架整合总结
查看>>
图的深度优先遍历
查看>>