# Meaning of a varaible for calculating the partial derviative of MSE cost function

The equation to find the partial derivative of a cost function with respect to a parameter θj is given in the book 'Hands on Machine Learning with scikit-learn, keras and tensorflow ': • m = number of instances in the dataset
• x = input vector for the prediction
• y = label for the input vector

I am not able to understand what the last scalar x(i)j means. Could someone please tell me what the variable means.

From the context you have provided, my reading is that $$x^{(i)}_j$$ is the $$j$$-th element of the $$i$$-th input vector $$\mathbf{x}^{(i)}$$, where there are $$i = 1,..., m$$ training instances.

In response to:

So in the case where $$j = 1$$, that is, $$\theta_j = \theta_1$$, then $$x^{(i)}_j$$ would be the 1st element of $$\mathbf{x}^{(i)}$$.

Yes you are entirely correct.

And in response to:

E.g : If $$\mathbf{x}^{(i)} = [1,2,3,4,5]$$ and $$\theta_j = \theta_1$$ then $$x^{(i)}_j$$ = 2 (considering 0 to be the first index).

This is just my view, but my personal preference, and also advice, is to make a distinction between formal "mathematics-indexing" which you see in mathematics in print, and implementational "Python-indexing". This is to avoid confusion.

In the case of mathematics-indexing, which is the convention for indexing vectors like $$\mathbf{x}^{(i)}$$ in print, then in your case $$j = 1, ... 5$$. In this case, then in your example $$x^{(i)}_1 = 1$$, i.e. the first element of the vector $$\mathbf{x}^{(i)}$$.

In the case of (what I am assuming to be) Python-indexing, which is what you will need for implementation, then $$j = 0, ..., 4$$. For your example, under this convention, then you are correct, $$x^{(i)}_1 = 2$$. Having now checked the book this is correct, Geron is using $$j = 0, ..., n$$ to index $$(n+1)$$ elements of the vector $$\mathbf{x}^{(i)}$$.

• So if θj = θ1, then x(i)j would be the 1st element of x(i). E.g : If x(i) = [1,2,3,4,5] and θj = θ1 then x(i)j = 2 (considering 0 to be the first index). – Arya Man Apr 1 at 20:04
• Thank you, that helps. – Arya Man Apr 1 at 20:42
• Having now looked at the book - you are correct on both counts, the author is using using $j= 0, ..., n$ to index the $(n+1)$ elements of $\mathbf{x}^{(i)}$. – microhaus Apr 1 at 20:45
• Sorry, but could I ask a small follow-up question? If θj = 5 then should the jth element in θ also be 5? E.g - If on the left hand side θj= θ3 = 5 then should the θ on the right-hand-side of the equation be [θ0, θ1, θ2, 5, θ4, θ5, θ6]? – Arya Man Apr 2 at 0:31
• I will use a new response to answer your new question at stats.stackexchange.com/questions/517820/… and address this final comment in the new response – microhaus Apr 2 at 11:47