I am not able to get the logic?

why we are using (Y -…) in 3d plot to calculate J[i,j] value

Hi @Deepanshu_garg,

Firstly understand that we need a 3D plot for this case, since we have theta0, theta1 and we want the error in the Z direction.

the elevation or Z-axis is the error of each example.

and how do we calculate error : J = sum[(Y - hx)**2] where : hx = theta1*X + theta0

This is the formula implemented there, just replaced the theta with T, and iterate over all the example to form the correct matrix. so that for every example we can calculate the error and give the elevation equal to the error of that point.
If high error high elevation , low error low elevation. That’s how we are plotting this graph.

I hope you got this statement now :slight_smile: