I've been trying to figure out how to output two metrics to a chart I'm trying to display. I looked around on here and found that the way to do this was via the plt.text
I've tried about 80 different variations and I still can't get it to ouput.
This is my latest code:
mae = metrics.mean_absolute_error(y_test,y_pred)
mse = metrics.mean_squared_error(y_test, y_pred)
y_df = pd.DataFrame(index=pd.to_datetime(test_index))
y_pred = y_pred.reshape(len(y_pred), )
y_test = y_test.reshape(len(y_test), )
y_df['y_pred'] = y_pred
y_df['y_test'] = y_test
y_df.plot(title='{}'.format(gsc.best_estimator_))
plt.text(.5, .5, 'MAE:{}\nMSE:{}'.format(mae, mse))
plt.tight_layout()
plt.show(block=False)
print('end')
plt.show()
My chart will print - but no text. I've tried switching from the pandas
matplotlib
wrapper and plotting directly with plt.plot
but still couldn't get it to run. Any Ideas on what I'm doing wrong?
Edit: I've tried to go away from using the pandas wrapper to plot again. Now i'm getting:
mae = metrics.mean_absolute_error(y_test,y_pred)
mse = metrics.mean_squared_error(y_test, y_pred)
y_df = pd.DataFrame(index=pd.to_datetime(test_index))
y_pred = y_pred.reshape(len(y_pred), )
y_test = y_test.reshape(len(y_test), )
y_df['y_pred'] = y_pred
y_df['y_test'] = y_test
line1 = Line2D(test_index, y_pred,color="goldenrod")
line2 = Line2D(test_index, y_test, color="dodgerblue")
#y_df.plot(title='{}'.format(gsc.best_estimator_))
plt.text(.5, .5, 'MAE:{}\nMSE:{}'.format(mae, mse))
plt.tight_layout()
plt.show(block=False)
print('end')
plt.show()