2

I ran an lstm model 10 times and averaged the values to get the mean and that became my predicted value. I calculated the standard diviation of each row and added it to my dataframe (test_iterations)that contains my predicted values. I now want to plot error bars so my graph can look like this (that was done in excel) enter image description here

But when i use the following code i get a graph that looks like this

plt.errorbar(test_iterations['Mean'].values, 
                     test_iterations['Mean'].values,
                     yerr = test_iterations['Stdv'].values,
                     fmt='-o')

enter image description here

I'm not sure what am doing is even right because i added x and y values on the code of the same thing but wasn't sure what to add there

1

1 Answer 1

2

The first argument of plt.errorbar() is the x coordinates of the points to plot. In your case, it is the rank of the value.

Try this:

import numpy as np

plt.errorbar(np.arange(len(test_iterations['Mean'])),
             test_iterations['Mean'].values,
             yerr=test_iterations['Stdv'].values,
             fmt='-o')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.