字幕表 動画を再生する
In order to implement linear regression, the first key step is for us to define something called a cost function.
線形回帰を実行するために、最初の重要なステップは、コスト関数と呼ばれるものを定義することである。
This is something we'll build in this video.
これは、このビデオで作り上げるものだ。
The cost function will tell us how well the model is doing so that we can try to get it to do better.
コスト関数は、モデルがどの程度うまくいっているかを教えてくれる。
Let's look at what this means.
この意味を見てみよう。
Recall that you have a training set that contains input features x and output targets y.
入力特徴xと出力ターゲットyを含むトレーニングセットを持っていることを思い出してください。
The model you're going to use to fit this training set is this linear function fwp of x equals w times x plus b.
このトレーニングセットに適合させるために使用するモデルは、xの一次関数fwpは、w×x+bに等しい。
To introduce a little bit more terminology, the w and b are called the parameters of the model.
もう少し専門用語を紹介すると、wとbはモデルのパラメータと呼ばれる。
In machine learning, parameters of a model are the variables you can adjust during training in order to improve the model.
機械学習では、モデルのパラメータとは、モデルを改善するために学習中に調整できる変数のことである。
Sometimes you also hear the parameters w and b referred to as coefficients or as weights.
パラメータwやbを係数や重みと呼ぶこともある。
Now, let's take a look at what these parameters w and b do.
では、これらのパラメーターwとbが何をするのかを見てみよう。
Depending on the values you've chosen for w and b, you get a different function f of x, which generates a different line on the graph.
wとbに選んだ値によって、xの関数fは異なり、グラフ上に異なる線を描く。
Remember that we can write f of x as a shorthand for fwp of x.
xのfはxのfwpの省略形として書けることを覚えておこう。
We're going to take a look at some plots of f of x on a chart.
xのfのグラフをいくつか見てみよう。
Maybe you're already familiar with drawing lines on charts, but even if this is a review for you, I hope this will help you build intuition on how w and b, the parameters, determine f.
もしかしたら、チャートに線を引くことにはすでに慣れているかもしれないが、復習だとしても、パラメータであるwとbがどのようにfを決定するのか、直感を養う一助になれば幸いである。
When w is equal to 0 and b is equal to 1.5, then f looks like this horizontal line.
wが0、bが1.5のとき、fはこのような水平線になる。
In this case, the function f of x is 0 times x plus 1.5, so f is always a constant value.
この場合、xの関数fは0×x+1.5なので、fは常に定数となる。
It always predicts 1.5 for the estimated value of y, so y hat is always equal to b.
yの推定値は常に1.5と予測されるため、yハットは常にbと等しくなる。
Here, b is also called the y-intercept because that's where it crosses the vertical axis or the y-axis on this graph.
ここで、bはy切片とも呼ばれ、このグラフの縦軸またはy軸と交差する場所だからである。
As a second example, if w is 0.5 and b is equal to 0, then f of x is 0.5 times x.
第2の例として、wが0.5でbが0に等しい場合、xのfはxの0.5倍となる。
When x is 0, the prediction is also 0, and when x is 2, then the prediction is 0.5 times 2, which is 1.
xが0の時、予測値も0となり、xが2の時、予測値は2の0.5倍で1となる。
You get a line that looks like this.
次のようなラインが表示される。
Notice that the slope is 0.5 divided by 1, so the value of w gives you the slope of the line, which is 0.5.
傾きは0.5を1で割った値なので、wの値から直線の傾きがわかる。
Finally, if w equals 0.5 and b equals 1, then f of x is 0.5 times x plus 1.
最後に、wが0.5でbが1の場合、xのfはxの0.5倍に1を足したものになる。
When x is 0, then f of x equals b, which is 1.
xが0のとき、xのfはbに等しく、これは1である。
The line intersects the vertical axis at b, the y-intercept.
直線はy切片であるbで縦軸と交差する。
Also, when x is 2, then f of x is 2, so the line looks like this.
また、xが2のとき、xのfは2なので、線は次のようになる。
Again, the slope is 0.5 divided by 1, so the value of w gives you the slope, which is 0.5.
ここでも、傾きは0.5を1で割った値なので、wの値から傾きが求まり、0.5となる。
Recall that you have a training set like the one shown here.
ここに示したようなトレーニングセットがあることを思い出してほしい。
With linear regression, what you want to do is to choose values for the parameters w and b, so that the straight line you get from the function f somehow fits the data well, like maybe this line shown here.
線形回帰では、関数fから得られる直線が、ここに示す直線のように、データにうまくフィットするように、パラメータwとbの値を選ぶことである。
When I say that the line fits the data visually, you can think of this to mean that the line defined by f is roughly passing through or somewhat close to the training examples as compared to other possible lines that are not as close to these points.
直線が視覚的にデータにフィットしているというのは、fで定義される直線が、これらの点にそれほど近くない他の可能性のある直線と比較して、訓練例をほぼ通過しているか、いくらか近いことを意味すると考えることができる。
Just to remind you of some notation, a training example like this point here is defined by x superscript i, y superscript i, where y is the target.
ここで、いくつかの表記法を思い出してほしいのだが、この点のようなトレーニングの例は、上付き文字iのx、上付き文字iのyで定義される。
For a given input x i, the function f also makes a predicted value for y, and the value that it predicts for y is y hat i shown here.
与えられた入力x iに対して、関数fはyの予測値も作り、yの予測値はここに示すy hat iとなる。
For our choice of a model, f of x i is w times x i plus b.
私たちが選んだモデルでは、x iのfはx iのw倍にbを足したものになる。
Stated differently, the prediction y hat i is f of w b of x i, where for the model we're using, f of x i is equal to w x i plus b.
別の言い方をすれば、予測値y hat iはx iのw bのfであり、我々が使っているモデルでは、x iのfはw x iにbを足したものに等しい。
So now the question is, how do you find values for w and b so that the prediction y hat i is close to the true target y i for many or maybe all training examples x i, y i?
では、どのようにしてwとbの値を求めれば、多くの、あるいはおそらくすべてのトレーニング例x i, y iに対して、予測値y hat iが真のターゲットy iに近くなるのだろうか?
To answer that question, let's first take a look at how to measure how well a line fits the training data.
その質問に答えるために、まず、線が訓練データにどの程度フィットするかを測定する方法を見てみよう。
To do that, we're going to construct our cost function.
そのために、コスト関数を構築する。
The cost function takes the prediction y hat and compares it to the target y by taking y hat minus y.
コスト関数は、予測値y hatを取り、y hatからyを引いたものを目標値yと比較する。
This difference is called the error.
この差を誤差と呼ぶ。
We're measuring how far off the prediction is from the target.
私たちは、予測が的からどれだけ外れているかを測っている。
Next, let's compute the square of this error.
次に、この誤差の2乗を計算してみよう。
Also, we're going to want to compute this term for different training examples i in the training set.
また、トレーニング・セットの異なるトレーニング例iについてこの項を計算したい。
So when measuring the error, for example, i, we'll compute this squared error term.
そこで、例えばiの誤差を測定する場合、この誤差の二乗項を計算する。
Finally, we want to measure the error across the entire training set.
最後に、トレーニングセット全体の誤差を測定したい。
In particular, let's sum up the squared errors like this.
特に、二乗誤差を次のように合計してみよう。
We'll sum from i equals 1, 2, 3, all the way up to m.
iが1、2、3、mまでの和をとる。
Remember that m is the number of training examples, which is 47 for this dataset.
mは学習例の数で、このデータセットでは47であることを思い出してほしい。
Notice that if we have more training examples, m is larger and your cost function will calculate a bigger number since it's summing over more examples.
訓練例が多ければ、mは大きくなり、コスト関数はより多くの例について合計するので、より大きな数値を計算することに注意してください。
So to build a cost function that doesn't automatically get bigger as the training set size gets larger, by convention, we will compute the average squared error instead of the total squared error and we do that by dividing by m like this.
そこで、トレーニングセットのサイズが大きくなっても自動的に大きくならないようなコスト関数を構築するために、慣例として、総二乗誤差の代わりに平均二乗誤差を計算することにし、次のようにmで割ることで計算する。
We're nearly there.
あと少しだ。
Just one last thing.
最後にもうひとつだけ。
By convention, the cost function that machine learning people use actually divides by 2 times m.
慣例として、機械学習者が使うコスト関数は、実際にはmを2で割る。
The extra division by 2 is just meant to make some of our later calculations a little bit neater, but the cost function still works whether you include this division by 2 or not.
2による余分な除算は、後の計算を少しすっきりさせるためのものだが、この2による除算を含んでも含まなくても、コスト関数は機能する。
This expression right here is the cost function and we're going to write J of WB to refer to the cost function.
この式はコスト関数で、WBのJと書いてコスト関数を指すことにする。
This is also called the squared error cost function and it's called this because you're taking the square of these error terms.
これは二乗誤差コスト関数とも呼ばれ、誤差項の二乗を取ることからこう呼ばれる。
In machine learning, different people will use different cost functions for different applications.
機械学習では、人によって用途に応じて異なるコスト関数を使う。
But the squared error cost function is by far the most commonly used one for linear regression, and for that matter, for all regression problems, where it seems to give good results for many applications.
しかし,2乗誤差コスト関数は,線形回帰,そしてそれに関してはすべての回帰問題で,圧倒的に最もよく使われる関数であり,多くの応用で良い結果を与えるようである.
Just as a reminder, the prediction y hat is equal to the output of the model f at x.
念のために言っておくが、予測値y hatはxにおけるモデルfの出力に等しい。
We can rewrite the cost function J of WB as 1 over 2m times the sum from i equals 1 to m of f of x, i minus yi, the quantity squared.
WBのコスト関数Jは、iからxのfの1倍からm倍までの総和の2m倍の1倍からyiを引いた量の2乗と書き換えることができる。
Eventually, we're going to want to find values of W and B that make the cost function small.
最終的には、コスト関数が小さくなるようなWとBの値を見つけることになる。
But before going there, let's first gain more intuition about what J of WB is really computing.
しかし、その前にまず、J.O.WBが実際にどのようなコンピューティングをしているのか、もっと直感的に理解しよう。
At this point, you might be thinking we've done a whole lot of math to define the cost function, but what exactly is it doing?
この時点で、コスト関数を定義するためにたくさんの計算をしたと思うかもしれない。
Let's go on to the next video where we'll step through one example of what the cost function is really computing, that I hope will help you build intuition about what it means if J of WB is large versus if the cost J is small.
次のビデオでは、WBのJが大きい場合とJが小さい場合のコスト関数の意味を直感的に理解するのに役立つと思う。
Let's go on to the next video.
次のビデオに行こう。