user8705895
user8705895

Reputation:

Compute the MSE of this set of points (X, Y) with respect to the given regression model

I am new to Machine learning . I am trying to find out MSE for given regression model linear regression line (model): y=7.93+1.12x. The data values for X and Y are (23, 41), (34, 45), (45, 49), (56,67), (67, 84), (78, 100).

Upvotes: -1

Views: 843

Answers (1)

Naman IIITD
Naman IIITD

Reputation: 26

That must be simple !!! MSE means mean square loss error. so assume your regression function is f(x) where x is the feature vector of dimension d. the output of f(x) is scaler. square error for one data sample(let it be x1,y1 ; x1 is a vector in d-dimensional space and y1 is scaler) is ( f(x1) - y )^2.

To calculate MSE, calculate the square error of each data point and then, add all square errors, divide the sum of square error by the number of data samples.

In your case, the dimension of the feature vector(x) is 1. and f(x) = 7.93 + 1.12*x.

----CODE----

X = (23,34,45,56,67,78)

Y = (41,45,49,67,84,100)

SE = 0.0

for x,y in X,Y :

 SE = SE + ( 7.93 + 1.12*x - y)**2

MSE = SE/ len(X)

Upvotes: 0

Related Questions