My Coding >
Programming language >
Python >
Python FAQ >
Python: How to calculate MAE - Mean Absolute Error
Python: How to calculate MAE - Mean Absolute ErrorThe cost function, or the overall distance between validating set and predicted set is very useful to estimate, how far is your prediction from real data. There are a lot of different cost function. Here I will show you haw to calculate MAE distance MAE – mean absolute error MAE = (1/n)*Σni=1(|yi-y’i|) where y is our target value and y' - our predicted value. Test data setLet’s make a simple dataset for calculation MAE value
and we can transfer these data to python numpy array
It is possible to use lists as well, but Numpy will give you more options and also will allow you to work with more faster computing by using CUDA. Calculating MAE with pure numpy
And the final code at one go
Sklearn MAE functionAnother way is to use already prepared MAE function in Sclean library (Scikit-learn is a free software machine learning library for the Python programming language). Sometimes it is very useful to know all these functions.
|
Last 10 artitles
9 popular artitles
|
|||||||||||||||||||||||||||||
© 2020 MyCoding.uk -My blog about coding and further learning. This blog was writen with pure Perl and front-end output was performed with TemplateToolkit. |