Coder Social home page Coder Social logo

pedrodbs / interestingnessxrl Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 0.0 492 KB

A python library for eXplainable Reinforcement Learning (XRL) based on the concept of interestingness elements.

License: GNU General Public License v3.0

Python 100.00%
reinforcement-learning explainable-ai explainable-rl introspection interestingness-elements highlights python

interestingnessxrl's Introduction


Project moved to: https://github.com/SRI-AIC/InterestingnessXRL





Interestingness XRL

framework

Interestingness XRL is a Python 3 library for eXplainable Reinforcement Learning (XRL) based on the concept of interestingness elements – these are elements of an agent’s history of interaction with its environment that might be relevant for understanding the agent’s aptitude, both its capabilities and limitations. The diagram above explains the workflow behind the framework. More details can be found in the accompanying paper.

Each element defines a specific criterion to evaluate the agent’s interaction. The library can be plugged-in to any standard RL task with minimal effort, and provides different reporting methods, namely video highlights and sequences, behavior heatmaps and elements’ tracker.

This framework provides implementations for standard RL algorithms like Q-Learning and SARSA. The code provides also a fully functional example for analyzing the behavior of different RL agents in the video-game of Frogger, but can easily be used with other environments that comply with OpenAI's Gym (Gym) interface.

Citation

Please cite the paper if you use the code in your research:

@misc{sequeira2019interestingness,
    title={Interestingness Elements for Explainable Reinforcement Learning: Understanding Agents' Capabilities and Limitations},
    author={Pedro Sequeira and Melinda Gervasio},
    year={2019},
    eprint={1912.09007},
    archivePrefix={arXiv},
    primaryClass={cs.LG}
}

License notice

The code is provided under the GPLv3 license. To use the code under a different set of licensing terms, please contact SRI International's licensing department at [email protected].

Installation

pip install -e git+https://github.com/pedrodbs/InterestingnessXRL.git

Dependencies

To use the Frogger environment, install with:

pip install -e git+https://github.com/pedrodbs/frogger.git

Usage

The following examples concern the default Frogger environment. All configurations can be edited in the default configurations file: interestingness_xrl/scenarios/frogger/configurations.py, including the number of episodes in each trial, the maximum timesteps per episode, the reward function, etc.

Train an agent for 100 trials via Q-learning using all available CPU cores:

python -m interestingness_xrl.bin.multi_agent_runner.py -a 0 -t 100 -p

Test an agent for 1 trial (default = 2,000 episodes):

python -m interestingness_xrl.bin.agent_runner.py -a 1 -t 0 -p -v

Run introspection analysis over the train+test data to extract interestingness elements:

python -m interestingness_xrl.bin.analyzer.py -a 1

Extract visualizations/reports from the extracted elements:

python -m interestingness_xrl.bin.report.py -a 1 -r 1

Options for the -r parameter above (report type) include:

  • 0: Highlights, recording videos highlighting important times of the agent's interaction according to the extracted interestingness elements.
  • 1: Sequences highlights, a special case of a video highlight capturing a sequence element.
  • 2: Heatmaps, which produces images based on agent location frequencies, observation, feature frequencies, game stats means and elements frequencies.
  • 3: Tracker, producing several videos, each visually-tracking (attention map) the different interestingness elements on the environment.

interestingnessxrl's People

Contributors

pedrodbs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

interestingnessxrl's Issues

TyperError: Method Resolution Error

Facing the following issue when running
python -m interestingness_xrl.bin.multi_agent_runner.py -a 0 -t 100 -p directly after installing the repository. How to fix this?

Traceback (most recent call last):
  File "/home/abhik/miniconda3/envs/py37/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/home/abhik/miniconda3/envs/py37/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/home/abhik/InterestingnessXRL/interestingness_xrl/bin/multi_agent_runner.py", line 7, in <module>
    from interestingness_xrl.scenarios import AgentType
  File "/home/abhik/InterestingnessXRL/interestingness_xrl/scenarios/__init__.py", line 5, in <module>
    from interestingness_xrl.learning.explorations import ExpDecaySoftMax, SoftMaxExploration, ManualExploration, \
  File "/home/abhik/InterestingnessXRL/interestingness_xrl/learning/explorations.py", line 8, in <module>
    class ExplorationStrategy(object, ABC):
  File "/home/abhik/miniconda3/envs/py37/lib/python3.7/abc.py", line 126, in __new__
    cls = super().__new__(mcls, name, bases, namespace, **kwargs)
TypeError: Cannot create a consistent method resolution
order (MRO) for bases object, ABC

Possible ways to replicate an env.

For my research purposes, I'd like to be able to save a env object at it's current state and load it back later on.
When trying to save such an environment using pickle (for example when running agent_runner.py) it does not seems to work as expected.
Is there currently a method in your framework for doing so?

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.