【发布时间】:2021-11-19 03:56:30
【问题描述】:
我打算在我的图中绘制所有可能的信息,包括平均值、标准差和 MSE,并参考图中的每个点。
from sklearn.metrics import mean_absolute_error as mae
from sklearn.metrics import mean_squared_error as mse
import numpy as np
import matplotlib.pyplot as plt
为了简单起见,假设我只有三点。
true = np.array([[1047.]
[ 953.]
[1073.]])
pred = np.array([[ -69.921265]
[-907.8611 ]
[ 208.98877 ]])
my_mae= mae(true, pred) #mean absolute error
my_mse= mse(true,pred) #mean squared error
err = abs(true - pred) #get the error per point
mean_err = np.mean(err) #calculate the mean
sd_err = np.std(err) #calculate the standard deviation
然后,我绘制我的误差线。
dy= 100
plt.errorbar(true,pred, yerr=dy, fmt='o', color='black',ecolor='red', elinewidth=3, capsize=0);
首先,我想以某种方式引用每个错误栏以查看它引用的数据点。其次,我想将所有四条信息添加到情节中。如有任何帮助,我将不胜感激。
【问题讨论】:
-
“a”和“b”的值是多少?
-
这是一个错字,我现在改正了。
-
我的代码有什么不足吗?
标签: python numpy matplotlib plot