Skip to main content

A comprehensive, easy-to-use Python toolkit for reinforcement learning research and education

Project description

PyPiRL - Python Reinforcement Learning Toolkit

A comprehensive, easy-to-use Python toolkit for reinforcement learning research and education. Built with clean APIs, extensive documentation, and thorough testing.

🚀 Features

Core Algorithms

  • Q-Learning: Tabular off-policy value-based algorithm
  • SARSA: Tabular on-policy value-based algorithm
  • DQN: Deep Q-Network with PyTorch neural networks

Environments

  • SimpleGridWorld: Configurable grid environment with obstacles and goals
  • SimpleMaze: Customizable maze environment with walls

Policies

  • RandomPolicy: Uniform random action selection
  • GreedyPolicy: Always selects best action
  • EpsilonGreedyPolicy: Balances exploration/exploitation with decay
  • SoftmaxPolicy: Boltzmann exploration with temperature

Utility Functions

  • Training: train_agent() with progress tracking and early stopping
  • Evaluation: evaluate_agent() with performance metrics
  • Visualization: plot_learning_curve() and plot_comparison()
  • Persistence: save_agent() and load_agent() for model saving
  • Episode Running: run_episode() for single episode execution
  • Algorithm Comparison: compare_algorithms() for benchmarking

📦 Installation

From PyPI (when published)

pip install py-rl-toolkit

From Source

git clone https://github.com/Nits1627/PyPiRL.git
cd PyPiRL
pip install -e .

From Wheel

pip install dist/rltoolkit-0.1.0-py3-none-any.whl

🎯 Quick Start

from rltoolkit import QLearning, SimpleGridWorld, EpsilonGreedyPolicy

# Create environment and agent
env = SimpleGridWorld(size=5)
agent = QLearning(env.state_space_size, env.action_space_size)
policy = EpsilonGreedyPolicy(agent, epsilon=0.1)

# Train the agent
from rltoolkit import train_agent
rewards = train_agent(env, agent, policy, episodes=100)

# Evaluate performance
from rltoolkit import evaluate_agent
avg_reward = evaluate_agent(env, agent, policy, episodes=10)
print(f"Average reward: {avg_reward}")

📚 Examples

See examples.py for comprehensive usage examples including:

  • Training different algorithms
  • Comparing algorithm performance
  • Visualizing learning curves
  • Custom environment creation

🧪 Testing

Run the comprehensive test suite:

python -m pytest tests/ -v

📖 Documentation

Detailed documentation is available in docs.md including:

  • API reference for all classes and functions
  • Algorithm explanations
  • Environment specifications
  • Policy implementations

🔧 Requirements

  • Python ≥ 3.7
  • NumPy
  • Matplotlib
  • PyTorch (for DQN)
  • TQDM (for progress bars)

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📊 Package Status

  • ✅ All 58 tests passing
  • ✅ Package successfully built
  • ✅ Ready for PyPI publication
  • ✅ GitHub Actions workflow configured for automated publishing

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

py_rl_toolkit-0.1.0.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

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

py_rl_toolkit-0.1.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for py_rl_toolkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e9e74c9f9a133d2a436af576973e67ac1f5fc243e3d233d8e9c90c7117ce414c
MD5 db5d8dfee30548695f9d129eb764a612
BLAKE2b-256 1789ba6e1fd69fe4928d8a48f3052702952f358df8e7f07db9170465546920d4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for py_rl_toolkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 530b815b3d002e69a54de9e8933dda7fb216fe7cba3a0579e60fc0d1c8e69c07
MD5 0fd7090e7732708efae67b715116668a
BLAKE2b-256 40a8d60a1349e46e0584efac42ea3cf181de92bcdd3363bf41b78d77566ccddc

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