A Policy Gradient RL agent for time series prediction using PyTorch Lightning.
Project description
TimeSeries Agent is a powerful reinforcement learning library designed for time series analysis and prediction. Built on top of PyTorch and PyTorch Lightning, it provides a flexible framework for training RL agents to work with time series data. It uses modern policy gradient algorithms like PPO and REINFORCE, and offers hyperparameter tuning using genetic algorithms.
This package is designed to predict the deviation direction of a time series that maximizes the reward (total and/or immediate).
Key Features
- Multiple policy gradient algorithms (PPO, REINFORCE, REINFORCE_STEP)
- Efficient hyperparameter tuning with genetic algorithms
- Simplified API for training and loading agents
- Support for custom reward functions
- Optimized visualization for training and validation metrics
- Easy integration with existing PyTorch workflows
- Support for custom time series datasets (multivariate)
- Built-in state normalization and reward calculation
- Flexible neural network architecture configuration
- Real-time prediction capabilities
Installation
pip install timeseries-agent
Getting Started
We provide three interactive Colab tutorials to help you get started:
- Pattern BM Example - A benchmark synthetic dataset example.
- Genetic Tuner Tutorial - Shows how to use the Genetic Tuner to find optimal hyperparameters for your agent.
- Stock RL Example - An example of using the agent for stock price prediction.
Using Your Own Data
To use TimeSeries Agent with your own data, you need to prepare your time series data as a pandas DataFrame and use the train_from_csv function.
from timeseries_agent.api import train_from_csv
agent = train_from_csv(
csv_path="path/to/your/data.csv",
feature_cols=['your', 'feature', 'columns'],
target_col='your_target_column',
env_kwargs={'lookback': 10},
agent_kwargs={'agent_type': 'ppo'},
trainer_kwargs={'max_epochs': 50}
)
Key considerations when preparing your data:
- Ensure your DataFrame has no missing values
- The target column should contain the values you want to predict
- Additional features can help improve prediction accuracy
- The lookback period determines how much historical data the agent considers
- Ensure a balanced distribution of the actions you want to predict
Development
TimeSeries Agent is actively being developed on GitHub. Please note that the API is subject to change as we continue to improve and enhance the library.
Contributing
We welcome contributions to TimeSeries Agent! Whether it's improving documentation, adding new features, fixing bugs, or suggesting improvements, your help is appreciated. Feel free to submit pull requests or open discussions on GitHub.
Issues and Bug Reports
If you encounter any issues or bugs, please report them on our GitHub Issues page. Your feedback helps us improve the library and fix problems faster.
License
TimeSeries Agent is released under the Apache License 2.0 License. See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file timeseries_agent-0.1.1-py3-none-any.whl.
File metadata
- Download URL: timeseries_agent-0.1.1-py3-none-any.whl
- Upload date:
- Size: 42.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c36f190e16a141544443f97d50a4578544e9b15ede3520ab3592fab09f769c95
|
|
| MD5 |
76be2d52f5bcbee066b1669052985cb9
|
|
| BLAKE2b-256 |
0ecb95affa9aade7d8e8a6c83c7e3b9537586f3f83aada4fd6a05e1871c5db91
|