pedrodbs / InterestingnessXRL

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


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 licensee-ops@sri.com.

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.

About

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

License:GNU General Public License v3.0


Languages

Language:Python 100.0%