0

Sorry If my question is too naive, I am learning Machine Learning course in that course instructor has taken a linear function

h(x) = theta + theta1(x)

here is an actual data

where x is the input which needs to be given

and y is the actual value and h(x) is a hypothetical value

inorder to reduce the difference between x and h(x) instructor proposed

to square the difference i.e. (h(x)-y)^2

If we consider if its is being solely done to encounter the negative values but It would give me wrong output when I consider the case

h(x) > y, h(x)-y>0 and if we square it (h(x)-y)^2 would be even more isnt it?

Why is it being done, I am unable to understand.

Can somebody shed some light on this?

Thanks a lot in advance

Siddartha C.S

Siddarth
  • 143

1 Answers1

1

This is so that if $h(x)=y$, $(h(x)-y)^2$ is 0 and greater than $0$ otherwise, i.e. $h(x)=y$ is the minimum. If we don't square it, then we might find some $h(x)<y$ which would appear to be a better solution than the actual solution.

We could also minimise $|h(x)-y|$.

Steve
  • 127
  • Hi Steve, Thanks for the response in your case if h(x)=y then the difference of h(x) and y would be zero how it can be greater than zero? may be I am missing something please clarify – Siddarth Sep 26 '15 at 10:00
  • Looking for $x$ such that $h(x)=y$. If $h(x)>y$ then $h(x)-y > 0$ but if $h(x)<y$ then $h(x)-y<0$, which would be more minimal than the actual solution.

    Minimising would find the most negative solution, where as we want the nearest to zero. Alternativly we could take the absolute value of $h(x)-y$.

    – Steve Sep 26 '15 at 10:05