I was reading 'The Elements of Statistical Learning' and I am stuck on this excerpt on pg. 37 for a day now:
...This theory requires a loss function $L(Y, f(X))$ for penalizing errors in prediction, and by far the most common and convenient is squared error loss: $L(Y, f(X)) = (Y − f(X))$
This leads us to a criterion for choosing $f$, $$EPE(f) = E(Y − f(X))^2$$ $$ = \int [y-f(x)]^2 Pr(dx, dy)$$
the expected (squared) prediction error. By conditioning on X, we can write EPE as $$EPE(f) = E_X E_{Y|X} ([Y - f(X)]^2 | X)$$
and we see that it suffices to minimize EPE pointwise: $$f(x) = argmin_cE_{Y|X} ([Y - c]^2 | X = x)$$
The solution is: $$f(x) = E(Y |X = x)$$
I have got most of it now but ultimately I do not understand how we arrived at solution i.e. how did we solve the $argmin(.)$ step to get the final regression function; is it supposed to be intuitive or is there a particular technique to solve it? I only just learnt about $argmin$ function and its definition doesn't offer much explanation as to what is going on here. It is doubly important because they later on change the loss function and same approach is required later on.
Thank you!