The Mean Squared Error (MSE) or Mean Squared Deviation (MSD) of an estimator measures the average of error squares i.e. the average squared difference between the estimated values and true value. It is a risk function, corresponding to the expected value of the squared error loss. It is always non – negative and values close to zero are better. The MSE is the second moment of the error (about the origin) and thus incorporates both the variance of the estimator and its bias.
Steps to find the MSE
- Find the equation for the regression line.
- Insert X values in the equation found in step 1 in order to get the respective Y values i.e.
- Now subtract the new Y values (i.e. ) from the original Y values. Thus, found values are the error terms. It is also known as the vertical distance of the given point from the regression line.
- Square the errors found in step 3.
- Sum up all the squares.
- Divide the value found in step 5 by the total number of observations.
Consider the given data points: (1,1), (2,1), (3,2), (4,2), (5,4)
You can use this online calculator to find the regression equation / line.
Regression line equation: Y = 0.7X – 0.1
Now, using formula found for MSE in step 6 above, we can get MSE = 0.21606
MSE using scikit – learn:
MSE using Numpy module:
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- ML | Log Loss and Mean Squared Error
- ML | Mathematical explanation of RMSE and R-squared error
- Python - Non-Central Chi-squared Distribution in Statistics
- Python statistics | mean() function
- Finding Mean, Median, Mode in Python without libraries
- Python | Pandas dataframe.mean()
- numpy.mean() in Python
- Python | Pandas Series.mad() to calculate Mean Absolute Deviation of a Series
- sciPy stats.mean() function | Python
- Python | Pandas Series.mean()
- Python | Find Mean of a List of Numpy Array
- Python | Numpy matrix.mean()
- Absolute Deviation and Absolute Mean Deviation using NumPy | Python
- Numpy recarray.mean() function | Python
- Python | Mean of tuple list
- Numpy MaskedArray.mean() function | Python
- Python | Harmonic Mean of List
- Python - Ways to find Geometric Mean in List
- Python | Scipy stats.halfgennorm.mean() method
- Python | Scipy stats.hypsecant.mean() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.