training data in supervised models, case of linear regresion I have a newbie question about the case of linear regression or other supervised models for prediction. Imagine that I have the following dataset represented by the X array:



So we have n observations and p features, when I want to train a linear regression model I need to follow the formula:



which at the end can be transformed into the following summation:



At this point I have a doubt, let´s suppose that we have 3000 registers and 10 features with one variable for prediction. So, in my linear regression model (if I want it to program from scratch and not use any library) I should apply the summation formula for the 12 features 3000 times to fit the correct weights of theta. Is it like that? Any detailed explanation would be really helpful.

Thanks
no. of features $p$ 
no. of observations (training examples) $n$


In your example, $p = 10$ and $n = 3000$

So, what you said is right, you have to perform the following equation 3000 times.
$$h(x) = \sum_{i=0}^p \theta_{i}x_{i
}$$

and, see that the summation runs from $0$ to $p$, so a total of $p+1$ multiplications, with the first one $\theta_{0}$ being bias, and $x_{0}$ being $1$ always. 

If you have all $\theta_{i}$ values, at inference time for getting prediction for each test example, you perform the equation above, but the objective of linear regression is to find the values of $\theta$. This is nothing but called as fitting the model.

And the equation for finding $\theta_{i}$ values is

$$\theta_{i} := \theta_{i} - \frac{\alpha}{n} \sum_{j=1}^{n}(h^{j}(x)- y^{j})x^{j}$$ 

You can observe that calculation of $\theta$ also has the first equation $h(x)$,

where $\alpha$ is the Learning rate.