I am new to matlab and have just started on the UBC AI course. I used the least squares algorithm to generate the weights for the data-set I'm working with and the weights ive generated are [ 0.3400 ,-0.0553 , -0.0667]
.
Using the weights generated I predicted the value of y against the current data set (predictions are shown as x and the actual values are shown as circles). This brings me to the problem of trying to visualize the regression plane using the weights and the data I have. So basically my problem is how do you visualize the linear regression plane using the data I now have collected, or am I missing something?
and do the weights generated correspond to the y-intercept, slope and its orientation? If so how do they fit into the 2D plane equation?
Those weights you've generated are your regression coefficients, Beta0, Beta1
and Beta2
. If y
is your vertical axis and x1
, x2
are your features, or horizontal axes, they give you this equation for the plane:
y = Beta0 + Beta1*x1 + Beta2*x2
Which for you is: y = 0.3400 + -0.0553*x1 + -0.0667*x2
As for how to visualize this plane, we can find the answer at this SO answer
weights = [ 0.3400 ,-0.0553 , -0.0667];
[x1,x2]=ndgrid(-5:1:5,-5:1:5);
y = weights(1) + weights(2)*x1 + weights(3)*x2
figure
surf(x1,x2,y);