I'm getting coordinates from sensor and exporting received data in 2 column (x,y) in SQL table. I want to compare received data with ideal one and calculate RMSE from it. for example for a horizontal line from 0 to 5 cm, I received and exported about 200 rows of x , y in SQL table and obviously I can plot the ideal line in same figure also. is there any solution for getting RMSE from two plotted line in same figure? or I must generate ideal data and store in table and then compare them? Regards
Asked
Active
Viewed 398 times
-1
-
1If you have the values of the ideal line and the predicted line then you can use [RMSE with Python scikit learn library](https://www.askpython.com/python/examples/rmse-root-mean-square-error) – XXDIL Jan 05 '21 at 08:56
-
Thanks for your answer but as I said before, I don't have values of the ideal line. I mean I know that for example my ideal line is a horizontal line from 0 to 5 cm or a vertical line or circle with special radius but I don't have the data in table. (for 400 rows I must divide length in 400 and sum each of them with calculated amount !) I can calculate it for simple trajectories but for complex one, I don't know if it works or not.. – Rozhin.Vs Jan 05 '21 at 09:42
1 Answers
0
If you have your ideal values in the same table you can directly calculate it through an SQL query. The following is a MySQL query to achieve that,
select sqrt(avg(power(x - x_ideal, 2))) as RMSE_x,
sqrt(avg(power(y - y_ideal, 2))) as RMSE_y
from table
if you want to calculate RMSE in python, do this;
from sklearn.metrics import mean_squared_error as mse
rmse = mse(x, x_ideal, squared=False)
squared parameter defaults to true in which case it returns MSE value.

null
- 1,944
- 1
- 14
- 24
-
Thanks for your answer but the problem is I don't have my ideal values in same table. I can calculate and generate it with SQL query but for complicated shapes and trajectories it will be challenging! so I wonder if it is possible to calculate RMSE from two plotted chart or not? – Rozhin.Vs Jan 05 '21 at 09:36
-
I don't understand why u mean by two plotted chart, but I think if you can plot it through matplotlib (as question's tag suggest), then you must have a python array of your ideal values. In this case, just install sklearn by `pip install sklearn` and refer to the second code block. – null Jan 05 '21 at 16:05
-
I don't have the array for both charts. I have equation and start/end position for one chart and I have the array for another one. – Rozhin.Vs Jan 06 '21 at 05:49
-
Well, if you have an equation, you should be able to produce values, no ? and store them in an array ? – null Jan 06 '21 at 08:33
-