Given a target vector and a feature vector, how to computer the weight
The least square problem is to minimize $$\|Xw-t\|^2$$

Differentiating it with respect to $w$ and equating it to $0$, we have 

$$2X^T(Xw-t)=0$$

Hence, we have

$$X^TXw-X^Tt=0$$

That is $$X^TXw=X^Tt$$

$$w=(X^TX)^{-1}X^Tt$$