You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for i in range(5000):
rewards_sarsa.append(play_and_train(env, agent_sarsa))
rewards_ql.append(play_and_train(env, agent_ql))
#Note: agent.epsilon stays constant
if i %100 ==0:
clear_output(True)
print('EVSARSA mean reward =', np.mean(rewards_sarsa[-100:]))
print('QLEARNING mean reward =', np.mean(rewards_ql[-100:]))
plt.title("epsilon = %s" % agent_ql.epsilon)
plt.plot(moving_average(rewards_sarsa), label='ev_sarsa')
plt.plot(moving_average(rewards_ql), label='qlearning')
plt.grid()
plt.legend()
plt.ylim(-500, 0)
plt.show()`
the error message is :
`ImportError Traceback (most recent call last)
in ()
1 from IPython.display import clear_output
----> 2 from pandas import ewma, Series
3 # from pandas import Dataframe.ewm as ewm
4 moving_average = lambda ts, span=100: ewma(Series(ts), min_periods=span//10, span=span).values
5
ImportError: cannot import name 'ewma'
`
I tried googling it but I can't find a fix for it.
using python 3.5 and pandas 0.23.0 on ubuntu 16.04
The text was updated successfully, but these errors were encountered:
that worked, but a span value should be passed to the moving_average lambda function, here is the cell code that made it work
`
from IPython.display import clear_output
from pandas import DataFrame
moving_average = lambda x, span: DataFrame({'x':np.asarray(x)}).x.ewm(span=span).mean().values
rewards_sarsa, rewards_ql = [], []
for i in range(5000):
rewards_sarsa.append(play_and_train(env, agent_sarsa))
rewards_ql.append(play_and_train(env, agent_ql))
#Note: agent.epsilon stays constant
if i %100 ==0:
clear_output(True)
print('EVSARSA mean reward =', np.mean(rewards_sarsa[-100:]))
print('QLEARNING mean reward =', np.mean(rewards_ql[-100:]))
plt.title("epsilon = %s" % agent_ql.epsilon)
plt.plot(moving_average(rewards_sarsa,100), label='ev_sarsa')
plt.plot(moving_average(rewards_ql,100), label='qlearning')
plt.grid()
plt.legend()
plt.ylim(-500, 0)
plt.show()
I face an error from pandas when ever I run the cell containing
`from IPython.display import clear_output
from pandas import ewma, Series
moving_average = lambda ts, span=100: ewma(Series(ts), min_periods=span//10, span=span).values
rewards_sarsa, rewards_ql = [], []
for i in range(5000):
rewards_sarsa.append(play_and_train(env, agent_sarsa))
rewards_ql.append(play_and_train(env, agent_ql))
#Note: agent.epsilon stays constant
the error message is :
`ImportError Traceback (most recent call last)
in ()
1 from IPython.display import clear_output
----> 2 from pandas import ewma, Series
3 # from pandas import Dataframe.ewm as ewm
4 moving_average = lambda ts, span=100: ewma(Series(ts), min_periods=span//10, span=span).values
5
ImportError: cannot import name 'ewma'
`
I tried googling it but I can't find a fix for it.
using python 3.5 and pandas 0.23.0 on ubuntu 16.04
The text was updated successfully, but these errors were encountered: