200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > 机器学习均方误差_机器学习:均方误差和回归线简介

机器学习均方误差_机器学习:均方误差和回归线简介

时间:2018-10-25 19:52:58

相关推荐

机器学习均方误差_机器学习:均方误差和回归线简介

机器学习均方误差

by Moshe Binieli

由Moshe Binieli

机器学习:均方误差和回归线简介 (Machine learning: an introduction to mean squared error and regression lines)

介绍(Introduction)

This article will deal with the statistical methodmean squared error, and I’ll describe the relationship of this method to theregression line.

本文将讨论统计方法的均方误差,并描述该方法与回归线的关系。

The example consists of points on the Cartesian axis. We will define a mathematical function that will give us the straight line that passes best between all points on the Cartesian axis.

该示例由笛卡尔轴上的点组成。 我们将定义一个数学函数,该函数将为我们提供在笛卡尔轴上所有点之间最佳通过的直线。

And in this way, we will learn the connection between these two methods, and how the result of their connection looks together.

这样,我们将学习这两种方法之间的联系,以及它们的联系结果如何看待。

一般说明 (General explanation)

This is the definition from Wikipedia:

这是维基百科的定义:

In statistics, the mean squared error (MSE) of an estimator (of a procedure for estimating an unobserved quantity) measures the average of the squares of the errors — that is, the average squared difference between the estimated values and what is estimated. MSE is a risk function, corresponding to the expected value of the squared error loss. The fact that MSE is almost always strictly positive (and not zero) is because of randomness or because the estimator does not account for information that could produce a more accurate estimate.
在统计中,估计器(用于估计未观察到的数量的过程的估计器)的均方误差(MSE)测量误差平方的平均值,即,估计值与估计值之间的均方差。 MSE是一个风险函数,对应于平方误差损失的期望值。 MSE几乎始终严格为正数(而不是零)的事实是由于随机性,或者是因为估算器没有考虑可能产生更准确估算的信息。

文章的结构 (The structure of the article)

Get a feel for the idea, graph visualization, mean squared error equation.了解一下这个想法,图形可视化,均方误差方程。

The mathematical part which contains algebraic manipulations and a derivative of two-variable functions for finding a minimum. This section isfor those who want to understand howwe get the mathematical formulas later, you can skip it if that doesn’t interest you.

数学部分,其中包含代数操作和用于寻找最小值的二变量函数的导数。 本节适用于那些想了解我们以后如何获得数学公式的人,如果您不感兴趣,可以跳过它。

An explanation of the mathematical formulae we received and the role of each variable in the formula.对我们收到的数学公式的解释,以及每个变量在公式中的作用。 Examples例子

感受一下这个主意 (Get a feel for the idea)

Let’s say we have seven points, and our goal is to find a line thatminimizesthe squared distances to these different points.

假设我们有七个点,我们的目标是找到一条线,以最小化到这些不同点的平方距离。

Let’s try to understand that.

让我们尝试了解一下。

I will take an example and I will draw a line between the points. Of course, my drawing isn’t the best, but it’s just for demonstration purposes.

我将举一个例子,并在两点之间画一条线。 当然,我的绘画不是最好的,但这只是出于演示目的。

You might be asking yourself, what is this graph?

您可能会问自己,这张图是什么?

thepurple dotsare the points on the graph. Each point has an x-coordinate and a y-coordinate.

紫色点是图形上的点。 每个点都有一个x坐标和一个y坐标。

Theblue lineis our prediction line. This is a line that passes through all the points and fits them in the best way. This line contains the predicted points.

蓝线是我们的预测线。 这是一条穿过所有点并以最佳方式拟合它们的线。 该行包含预测点。

Thered linebetween each purple point and the prediction line are theerrors.Each error is the distance from the point to its predicted point.

每个紫色点和预测线之间的红线错误。每个误差是从点到其预测点的距离。

You should remember this equation from your school days,y=Mx+B, whereMis the slope of the line andBis y-intercept of the line.

您应该记得上学时的方程,y = Mx + B,其中M是直线的斜率 ,B是直线的y截距 。

We want to find M (slope) and B (y-intercept) thatminimizesthe squared error!

我们想要找到最小化平方误差的M( 斜率 )和B( y截距 )!

Let’s define a mathematical equation that will give us the mean squared error for all our points.

让我们定义一个数学方程式,它将为我们提供所有点的均方误差。

Let’s analyze what this equation actually means.

让我们分析一下这个方程的实际含义。

In mathematics, the character that looks like weird E is called summation (Greek sigma). It is the sum of a sequence of numbers, from i=1 to n. Let’s imagine this like an array of points, where we go through all the points, from the first (i=1) to the last (i=n).在数学中,看起来像奇怪的E的字符称为求和(Greek sigma)。 它是从i = 1到n的数字序列的总和。 让我们想象这就像一个点数组,我们从头一个点(i = 1)到最后一个点(i = n)遍历所有点。 For each point, we take the y-coordinate of the point, and the y’-coordinate. The y-coordinate is our purple dot. The y’ point sits on the line we created. We subtract the y-coordinate value from the y’-coordinate value, and calculate the square of the result.对于每个点,我们采用该点的y坐标和y'坐标。 y坐标是我们的紫色圆点。 y'点位于我们创建的直线上。 我们从y'坐标值中减去y坐标值,然后计算结果的平方。 The third part is to take the sum of all the (y-y’)² values, and divide it by n, which will give the mean.第三部分是取所有(y-y')²值的总和,然后除以n,得到平均值。

Our goal is to minimize this mean, which will provide us with the best line that goes through all the points.

我们的目标是尽量减少这种均值,这将为我们提供贯穿所有要点的最佳路线。

从概念到数学方程 (From concept to mathematical equations)

This part isfor people who want to understand how we got to the mathematical equations. You can skip to the next part if you want.

这部分适用于那些想了解我们如何掌握数学方程的人们。 您可以根据需要跳到下一部分。

As you know, the line equation is y=mx+b, where m is the slope and b is the y-intercept.

如您所知,线方程为y = mx + b,其中m为斜率 ,b为y截距 。

Let’s take each point on the graph, and we’ll do our calculation (y-y’)².But what is y’, and how do we calculate it? We do not have it as part of the data.

让我们以图形上的每个点为例,进行计算(y-y')²。但是y'是什么,如何计算呢? 我们没有将其作为数据的一部分。

But we do know that, in order to calculate y’, we need to use our line equation, y=mx+b, and put the x in the equation.

但是我们确实知道,为了计算y',我们需要使用线方程y = mx + b,并将x放入方程中。

From here we get the following equation:

从这里我们得到以下等式:

Let’s rewrite this expression to simplify it.

让我们重写此表达式以简化它。

Let’s begin by opening all the brackets in the equation. I colored the difference between the equations to make it easier to understand.

首先打开方程式中的所有方括号。 我为方程式之间的差异着色,以使其更易于理解。

Now, let’s apply another manipulation. We will take each part and put it together. We will take all the y, and (-2ymx) and etc, and we will put them all side-by-side.

现在,让我们应用另一种操作。 我们将把各个部分放到一起。 我们将取所有y和(-2ymx)等,并将它们并排放置。

At this point we’re starting to be messy, so let’s take the mean of all squared values for y, xy, x, x².

在这一点上,我们开始变得混乱,因此让我们取y,xy,x,x²的所有平方值的平均值。

Let’s define, for each one, a new character which will represent the mean of all the squared values.

让我们为每一个定义一个新字符,它将代表所有平方值的均值。

Let’s see an example, let’s take all the y values, and divide them by n since it’s the mean, and call it y(HeadLine).

让我们看一个例子,让我们获取所有y值,然后将它们除以n(因为这是平均值),然后将其称为y(HeadLine)。

If we multiply both sides of the equation by n we get:

如果将方程式的两边都乘以n,我们将得到:

Which will lead us to the following equation:

这将导致我们得出以下等式:

If we look at what we got, we can see that we have a 3D surface. It looks like a glass, which rises sharply upwards.

如果我们看看所得到的,我们可以看到我们具有3D表面。 它看起来像玻璃,它急剧上升。

We want to find M and B that minimize the function. We will make a partial derivative with respect to M and a partial derivative with respect to B.

我们想要找到使功能最小化的M和B。 我们将对M进行偏导数,对B进行偏导数。

Since we are looking for a minimum point, we will take the partial derivatives and compare to 0.

由于我们正在寻找一个最小值,因此我们将偏导数与0进行比较。

Let’s take the two equations we received, isolating the variable b from both, and then subtracting the upper equation from the bottom equation.

让我们以接收到的两个方程为例,将变量b与两个方程隔离开,然后从底部方程中减去上部方程。

Let’s subtract the first equation from the second equation

让我们从第二个方程式中减去第一个方程式

Let’s get rid of the denominators from the equation.

让我们摆脱方程式的分母。

And there we go, this is the equation to find M, let’s take this and write down B equation.

接下来,我们找到M的方程式,让我们写下B方程式。

斜率和y截距方程 (Equations for slope and y-intercept)

Let’s provide the mathematical equations that will help us find the required slope and y-intercept.

让我们提供数学方程式,以帮助我们找到所需的斜率和y截距 。

So you probably thinking to yourself, what the heck are those weird equations?

因此,您可能在想自己,这些怪异的方程式到底有什么用?

They are actually simple to understand, so let’s talk about them a little bit.

它们实际上很容易理解,所以让我们谈谈它们。

Now that we understand our equations it’s time to get all things together and show some examples.

现在我们已经了解了方程式,现在该将所有内容放在一起并展示一些示例了。

例子 (Examples)

A big thank you to Khan Academy for the examples.

非常感谢Khan Academy提供的示例。

例子1 (Example 1)

Let’s take 3 points, (1,2), (2,1), (4,3).

让我们取3分,(1,2),(2,1),(4,3)。

Let’s find M and B for the equation y=mx+b.

让我们为方程y = mx + b找到M和B。

After we’ve calculated the relevant parts for our M equation and B equation, let’s put those values inside the equations and get the slope and y-intercept.

在为M方程和B方程计算了相关部分之后,让我们将这些值放入方程中并获得斜率和y截距 。

Let’s take those results and set them inside the line equation y=mx+b.

让我们将这些结果放在线方程y = mx + b中。

Now let’s draw the line and see how the line passes through the lines in such a way that it minimizes the squared distances.

现在,让我们画一条线,看看线如何以最小化平方距离的方式穿过线。

例子2 (Example 2)

Let’s take 4 points, (-2,-3), (-1,-1), (1,2), (4,3).

让我们取4分,(-2,-3),(-1,-1),(1,2),(4,3)。

Let’s find M and B for the equation y=mx+b.

让我们为方程y = mx + b找到M和B。

Same as before, let’s put those values inside our equations to find M and B.

与以前一样,让我们​​将这些值放入方程式中以找到M和B。

Let’s take those results and set them inside line equation y=mx+b.

让我们将这些结果放在线方程y = mx + b中。

Now let’s draw the line and see how the line passes through the lines in such a way that it minimizes the squared distances.

现在,让我们画一条线,看看线如何以最小化平方距离的方式穿过线。

结论 (In conclusion)

As you can see, the whole idea is simple. We just need to understand the main parts and how we work with them.

如您所见,整个想法很简单。 我们只需要了解主要部分以及我们如何与他们合作。

You can work with the formulas to find the line on another graph, and perform a simple calculation and get the results for the slope and y-intercept.

您可以使用公式来查找另一张图上的线,并执行简单的计算并获得斜率和y截距的结果 。

That’s all, simple eh? ?

就这样,简单吗? ?

Every comment and all feedback is welcome — if it’s necessary, I will fix the article.

欢迎提出任何意见和所有反馈-如有必要,我将修复本文。

Feel free to contact me directly at LinkedIn — Click Here.

欢迎直接通过LinkedIn与我联系— 单击此处 。

翻译自: /news/machine-learning-mean-squared-error-regression-line-c7dde9a26b93/

机器学习均方误差

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。