Giter Club home page Giter Club logo

Comments (2)

justheuristic avatar justheuristic commented on May 18, 2024

THat's our mistake, we relied on a deprecated function from earlier pandas versions. Try this:

from pandas import DataFrame
moving_average = lambda x, span: DataFrame({'x':np.asarray(x)}).x.ewm(span=span).mean().values

We've also updated it on github

from practical_rl.

afakharany93 avatar afakharany93 commented on May 18, 2024

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()

`

from practical_rl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.