I could not quite comprehend the hypothesis represented by hθ(x)=θ0+θ1x To find out good values for the parameters θ0 and θ1 we want to minimize the difference between the calculated result and the actual result of our test data. So we subtract hθ(x(i))−y(i) for all i from 1 to m. Hence we calculate the sum over this difference and then calculate the average by multiplying the sum by 1/2m. This would result in:


So, I googled further and landed on a youtube video that talked about y=mx+b, where m is the slope and b is y intercept. This is called a Linear Model.

Also, in the linear model, the following formula is used to determine m and b.

Formula to arrive calculate m (slope) and b (y intercept

Now my questions are:

1) Is the hypotheses and the linear model the same? 2) Is there a cost function for the linear model? 3) Why would anyone want to guess, choose and arrive at θ0 and θ1 when there is a straight forward formula (linear model)?


1) Your hypothese $hθ(x)$ is clearly a linear model with $b \leftrightarrow θ_0$ and $m \leftrightarrow θ_1$ as you expected (don't be too hesitant and your colleges could have been able to confirm this).

2) Lets call $hθ(x_i)$ the prediction $p_i$. A cost function $C$ can be any function that when you try to minimize it holds a good solution. One example would be the mean squared error (mse): $C(p_i, y_i)=1/2 \cdot (p_i - y_i)^2$. I'm quite sure the mse is used to optimize the linear model, however other cost functions are possible.

3) I suppose this is an assignment? You clearly gave a very good suggestion to approximate your data. I suppose the goal of your task was to come to the solution of the linear model yourself. Try to understand how $b$ and $m$ is estimated in the linear model.

If you are in school, it is very useful to understand how people before you came to certain formula. It seems like you are reinventing the wheel, but the insights you gather with this can only help your education :).

Good luck.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.