INDEX

How do we know if we have a good line

So as we said before, our model is something that we learned from data.
And there are lots of complicated model types and lots of interesting ways we can learn from data.
But we're gonna start with something very simple and familiar.
This will open the gateway to more sophisticated methods.
Let's train a first little model from data.
So here we've got a small data set.
On the X axis, we've got our input feature, which is showing housing square footage.
On our Y axis, we've got the target value that we're trying to predict of housing price.
So we're gonna try and create a model that takes in housing square footage as an input feature and predicts housing price as an output feature.
Here we've got lots of little labeled examples in our data set.
And I'm go ahead and channel our inner ninth grader to fit a line.
It can maybe take a look at our data set and fit a line that looks about right here. Maybe something like this.
And this line is now a model that predicts housing price given an input.
We can recall from algebra one that we can define this thing as Y = WX + B.
Now in high school algebra we would have said MX, here we say W because it's machine learning.
And this is referring to our weight vectors.
Now you'll notice that we've got a little subscript here because we might be in more than one dimension.
This B is a bias.
and the W gives us our slope.
How do we know if we have a good line?
Well, we might wanna think of some notion of loss here.
Loss is showing basically how well our line is doing at predicting any given example.
So we can define this loss by looking at the difference between the prediction for a given X value
and the true value for that example.
So this guy has some moderate size loss.
This guy has near-zero loss.
Here we've got exactly zero loss.
Here we probably have some positive loss.
Loss is always on a zero through positive scale.
How might we define loss? Well, that's something that we'll need to think about in a slightly more formal way.
So let's think about one convenient way to define loss for regression problems.
Not the only loss function, but one useful one to start out with.
We call this L2 loss, which is also known as squared error.
And it's a loss that's defined for an individual example by taking the square of the difference between our model's prediction and the true value.
Now obviously as we get further and further away from the true value, the loss that we suffer increases with a square.
Now, when we're training a model we don't care about minimizing loss on just one example, we care about minimizing loss across our entire data set.

Linear Regression

如何由 labeled examples 得到一个线性关系?(model)

假设我们要给温度(y)和蟋蟀每分钟的叫声(x)建立模型。可以这么做:

  1. 利用已有的数据作出散点图
  2. 画一条简单的直线近似两者的关系
  3. 利用直线的方程,写出线性表达式,例如 y = wx + b

这里的 y 就是我们试图预测的东西,w 是直线的坡度, b 是 y 轴的截距, x 是特征(feature)

如果想要预测一个尚未发生的情况,只需要把 feature 代入模型就可以了。一个复杂的模型依赖更多的 feature ,每个 feature 都有独立的权重:

Training and Loss

训练一个模型仅仅意味着得到一条好的直线(这需要好的权重 w 和偏差 b)。

在监督学习中,机器学习算法检查很多的 example 并找到一个具有最小 loss 的模型,这个过程叫做 empirical risk minimization

loss 是一个数字,表明模型的预测在单个 example 上有多糟糕,如果模型的预测是完美的,那么 loss 为零; 否则,loss 更大。

训练模型的目标是找到一组对于整体数据而言、具有低 loss 的权重 w 和偏差 b 。

一种比较流行的计算 loss 的方式就是 squared loss (也被叫做L2 loss):

Mean square error (MSE) 是每个 example 的平均 squared loss

现在我们知道训练模型的目标了:找到具有低 loss 的直线,怎样才算低 loss 呢?平均方差最小的就是了,接下来的问题是,我们如何逼近这条直线?

Google's Machine Learning Crash Course #02# Descending into ML的更多相关文章

  1. Google's Machine Learning Crash Course #01# Introducing ML & Framing & Fundamental terminology

    INDEX Introducing ML Framing Fundamental machine learning terminology Introducing ML What you learn ...

  2. Google's Machine Learning Crash Course #03# Reducing Loss

    Goal of training a model is to find a set of weights and biases that have low loss, on average, acro ...

  3. Google's Machine Learning Crash Course #04# First Steps with TensorFlow

    1.使用 TensorFlow 的建议 Which API(s) should you use? You should use the highest level of abstraction tha ...

  4. 学习笔记之Machine Learning Crash Course | Google Developers

    Machine Learning Crash Course  |  Google Developers https://developers.google.com/machine-learning/c ...

  5. 课程三(Structuring Machine Learning Projects),第一周(ML strategy(1)) —— 0.Learning Goals

    Learning Goals Understand why Machine Learning strategy is important Apply satisficing and optimizin ...

  6. 课程三(Structuring Machine Learning Projects),第一周(ML strategy(1)) —— 1.Machine learning Flight simulator:Bird recognition in the city of Peacetopia (case study)

    []To help you practice strategies for machine learning, the following exercise will present an in-de ...

  7. 课程三(Structuring Machine Learning Projects),第二周(ML strategy(2)) —— 1.Machine learning Flight simulator:Autonomous driving (case study)

    [中文翻译] 为了帮助您练习机器学习的策略, 在本周我们将介绍另一个场景, 并询问您将如何行动.我们认为, 这个工作在一个机器学习项目的 "模拟器" 将给一个任务, 告诉你一个机器 ...

  8. 课程三(Structuring Machine Learning Projects),第二周(ML strategy(2)) —— 0.Learning Goals

    Learning Goals Understand what multi-task learning and transfer learning are Recognize bias, varianc ...

  9. ML Lecture 0-2: Why we need to learn machine learning?

    在Github上也po了这个系列学习笔记(MachineLearningCourseNote),觉得写的不错的小伙伴欢迎来给项目点个赞哦~~ ML Lecture 0-2: Why we need t ...

随机推荐

  1. ionic项目打包好Xcode工程,模拟器运行各种沙盒缓存目录

    用ionic开发好的app,build好iOS端可用的Xcode工程,然后用模拟器跑起来.研究一下js写的代码做本地持久化时,不同类型的文件都放在那里了. cordova-plugin-sqliteS ...

  2. MySQL Error 1215: Cannot add foreign key constraint

    MySQL Error 1215: Cannot add foreign key constraint DROP TABLE IF EXISTS `r_role_region`; CREATE TAB ...

  3. 前端开发组件化设计vue,react,angular原则漫谈

    前端开发组件化设计vue,react,angular原则漫谈 https://www.toutiao.com/a6346443500179505410/?tt_from=weixin&utm_ ...

  4. hmm三个问题

    现在,重点是要了解并解决HMM 的三个问题. 问题1,已知整个模型,我女朋友告诉我,连续三天,她下班后做的事情分别是:散步,购物,收拾.那么,根据模型,计算产生这些行为的概率是多少. 问题2,同样知晓 ...

  5. django模板语言转义处理

    模板变量的内容,如果含html的话,django的模板系统默认会对输出进行转义,比如把<p>转义成了<p> ,然后再显示出来的时候就如实地显示为<p>.要解决这个问 ...

  6. 洛谷P4436 游戏 [HNOI/AHOI2018]

    正解:拓扑排序 解题报告: 传送门! 首先不难想到可以把麻油锁的一段先直接缩成一个点,然后预处理每个点能到达的最左和最右节点,然后就能O(1)地查询辣 所以难点在于预处理 可以想到,对于它给定的关于锁 ...

  7. 正则表达式(三):Unicode诸问题下篇(转)

    原文:http://www.infoq.com/cn/news/2011/04/regular-expressions-4 我们使用正则表达式,熟练掌握各种功能和结构只是手段,解决实际的问题才是真正的 ...

  8. 创建list方法总结

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/sheismylife/article/details/28878593 构建一个list 注意要标记 ...

  9. vertx异步编程测试

    vertx是异步编程的框架,性能较高,开发简单.异步编程就是当一个请求来了,vertx将其交由一个事件进行处理,然后继续向下执行,等处理完成,返回结果,通知客户端.这是一个由服务端反向调用客户端的过程 ...

  10. [LeetCode] 116&117. Populating Next Right Pointers in Each Node I&II_Medium tag: BFS(Dont know why leetcode tag it as DFS...)

    Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *nex ...