Skip to main content

A lightweight, explainable, and constrained reinforcement learning toolkit.

Project description

🔐 SafeRL-Lite

A lightweight, explainable, and modular Python library for Constrained Reinforcement Learning (Safe RL) with real-time SHAP & saliency-based explainability, custom metrics, and Gym-compatible wrappers.


🌟 Overview

SafeRL-Lite empowers reinforcement learning agents to act under safety constraints, while remaining interpretable and modular for fast experimentation. It wraps standard Gym environments and DQN-based agents with:

  • ✅ Safety constraint logic
  • 🔍 Visual explainability (SHAP, saliency maps)
  • 📊 Violation and reward tracking
  • 🧪 Built-in testing and evaluations

🔧 Installation

📦 PyPI (coming soon)

pip install saferl-lite

🛠️ From source:

git clone https://github.com/satyamcser/saferl-lite.git
cd saferl-lite
pip install -e .

🚀 Quickstart

Train a constrained DQN agent with saliency-based explainability:

python train.py --env CartPole-v1 --constraint pole_angle --explain shap

🔹 This:

  • Adds a pole-angle constraint wrapper to the Gym env

  • Logs violations

  • Displays SHAP or saliency explanations for agent decisions

🧠 Features

✅ Constrained RL

  • Add custom constraints via wrapper or logic class

  • Violation logging and reward shaping

  • Safe vs unsafe episode tracking

🔍 Explainability

  • SaliencyExplainer — gradient-based visual heatmaps

  • SHAPExplainer — feature contribution values per decision

  • Compatible with any PyTorch-based agent

📊 Metrics

  • Constraint violation rate

  • Episode reward

  • Cumulative safe reward

  • Action entropy & temporal behavior stats

📚 Modularity

  • Swap out agents, constraints, evaluators, or explainers

  • Supports Gym environments

  • Configurable training pipeline

📜 Citation

Coming soon after arXiv/preprint release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

saferl_lite-0.1.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

saferl_lite-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file saferl_lite-0.1.0.tar.gz.

File metadata

  • Download URL: saferl_lite-0.1.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for saferl_lite-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3987091f369e10ab98d8db287ed96845a91287f77000b138d2c7788c8880137d
MD5 e0b6a15a4180c65e24b6c3b7a98cf3be
BLAKE2b-256 8fdb2c92a5795ec3245e694befe392e0ef2923981db4c9b3d6d6cb489e7f32c3

See more details on using hashes here.

File details

Details for the file saferl_lite-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: saferl_lite-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for saferl_lite-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18acb42e2183ac299087cba21c71fe240ceb84b20e2016f9d3563db130bc2038
MD5 34ffb5d2eabd660ff08f848cbe22cdd0
BLAKE2b-256 ada33a00b7a64d2e28b5460a600cbf78bd16d89475c62d7f265be8a33f766d30

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page