0
$\begingroup$

Can anyone help me about cost function in linear regression. As from the below plot we have actual values and predicted values and I assumed the answer as zero but it actually is 14/6?

Can anyone help out please?

enter image description here

$\endgroup$
3
$\begingroup$

$h_\theta$ implies that you're trying to model the relation between $h$ and $x$ with an straight line coming from the origin $(0,0)$. The parementer $\theta_1$ is the slope of this line.

Evaluating $J(\theta_1=0) = J(0)$, implies that $h_\theta(x_i)=0$ whatever the value of $x_i$ is. Since $m=3$, and the labels are $y_1=1, y_2=2, y_3=3$

$J(0) = \frac{1}{6}[(0 -1)^2 + (0 - 2)^2 + (0-3)^2] = \frac{14}{6}$

The value of $\theta_1$ for which $J(\theta_1) = 0$ is obviously 1

$\endgroup$
2
  • $\begingroup$ is y1=1 or y1=0? In the equation you did (0-1)^2? $\endgroup$ – Sai Kumar Dec 13 '18 at 6:29
  • $\begingroup$ is 1, of course... $\endgroup$ – ignatius Dec 13 '18 at 8:44

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.