x(i)
denote the “input” variables (living area in this example), also called input features, and
y(i)
denote the “output” or target variable that we are trying to predict (price).
A pair (x(i),y(i)) is called a training example
the dataset that we’ll be using to learn—a list of m training examples (x(i),y(i));i=1,...,m—is called a training set.
the superscript “(i)” in the notation is simply an index into the training set, and has nothing to do with exponentiation
X
denote the space of input values
Y
denote the space of output values
In this example
X = Y = R
复制代码
To describe the supervised learning problem slightly more formally, our goal is,
given a training set, to learn afunction h : X → Yso that h(x) is a “good” predictor for the corresponding value of y.
For historical reasons, this function h is called a hypothesis. Seen pictorially, the process is therefore like this
regression problem
When the target variable that we’re trying to predict iscontinuous, such as in our housing example
classification problem
When y can take on only a small number of discrete values (such as if, given the living area, we wanted to predict if a dwelling is a house or an apartment, say)
简单的介绍了一下数据集的表示方法,并且提出来h(hypothesis),即通过训练得出来的一个假设函数,通过输入x,得出来预测的结果y。并在最后介绍了线性回归方程
2 代价函数 - Cost Function
代价函数是用来测量实际值和预测值精确度的一个函数模型.
We can measure the accuracy of our hypothesis function by using acost function.
This takes an average difference (actually a fancier version of an average) of all the results of the hypothesis with inputs from x's and the actual output y's.
To break it apart, it is 1/2 x ̄ where x ̄ is the mean of the squares of hθ(xi)−yi , or the difference
between the predicted value and the actual value.
This function is otherwise called theSquared error function, or Mean squared error.
The mean is halved (1/2)as a convenience for the computation of the gradient descent, as the derivative term of the square function will cancel out the 1/2 term.
The following image summarizes what the cost function does:
3 代价函数(一)
If we try to think of it in visual terms, our training data set is scattered on the x-y plane.
We are trying to make a straight line (defined by hθ(x)) which passes through these scattered data points.
Our objective is to get the best possible line. The best possible line will be such so that the average squared vertical distances of the scattered points from the line will be the least.
Ideally, the line should pass through all the points of our training data set. In such a case, the value of J(θ0,θ1) will be 0.
The following example shows the ideal situation where we have a cost function of 0.
When θ1=1, we get a slope of 1 which goes through every single data point in our model.
Conversely, when θ1=0.5, we see the vertical distance from our fit to the data points increase.
This increases our cost function to 0.58. Plotting several other points yields to the following graph:
Thus as a goal, we should try to minimize the cost function. In this case, θ1=1 is our global minimum.