I was following Andrew NG ML course on coursera. I was stuck at cost function.enter image description here

How can I find values for Theta-0 and Theta-1 ?

So I came to know Theta-0 as y intercept so the values must be Theta-0 = 0.5 but how can I find the value for Theta-1?

Any help is appreciated.

  • $\begingroup$ $\theta_1$ is the slope, which can be eyeballed to be 1, since your line increases by 1 for every 1 increase in x. $\endgroup$ Commented Dec 6, 2018 at 12:19

1 Answer 1


Elaborating on the previous answer, now hat you have $\theta_0 = 0.5$, take any value of $x$ and the corresponding $h_\theta$ value to find $\theta_1$. For instance, using $x=1$ will yield:

$h_\theta(1) = \theta_0 + \theta_1 \times 1$

From the graphd, $h_\theta(1) = 1.5$ so that:

$\theta_0 + \theta_1 = 1.5$

$\theta_1 = 1.5 - \theta_0$

$\theta_1 = 1.5 - 0.5 = 1$

The final equation is then $h_\theta = 0.5 + x$

As said in the comment, you can also get the slope visually, noticing that if you increase $x$ by 1, $y$ also increases by 1 when you follow the slope.

Does this help?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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