import numpy as np
import plotly.graph_objects as go
=np.array([33,35,36,39,50,44,41,51,56,50,47,52,49,55,55,51,61,58,58,57,66])
y_actual=np.array([40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60])
y_predicted=go.Scatter(x=y_actual,y=y_predicted,mode="markers",name="scatter")
scatter_trace=go.Scatter(x=np.array([40,60]),y=np.array([40,60]),name="linear")
line_trace=go.Figure([scatter_trace,line_trace])
fig fig
1 二乗平均平方誤差
1.1 定義
\[ RMSE=\sqrt{\frac {\displaystyle\sum^{N}_{i=1}(予測値_i-実測値_i)^2} {N}} \]
1.2 Graph (plotly)
1.3 Graph (matplotlib)
import matplotlib.pyplot as plt
=plt.subplots()
fig,ax'.')
ax.plot(y_actual,y_predicted,40,60],[40,60],'-',color="green")
ax.plot([ plt.show()
1.4 RMSE
from sklearn.metrics import mean_squared_error
from math import sqrt
=sqrt(mean_squared_error(y_actual,y_predicted))
rmsprint("RSME: "+str(round(rms,2)))
RSME: 4.29
2 平均二乗パーセント誤差の平方根(RMSPE:Root Mean Squared Percentage Error)
工事中です
3 参考文献
4 Python version
import platform
"Python version "+platform.python_version()
'Python version 3.10.7'