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.
Metadata
Release files for timeseries-agent 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| timeseries_agent-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Release files / timeseries_agent-0.1.1-py3-none-any.whl
| Download URL | timeseries_agent-0.1.1-py3-none-any.whl |
|---|---|
| Size | 42.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c36f190e16a141544443f97d50a4578544e9b15ede3520ab3592fab09f769c95
|
|
BLAKE2b-256 checksum How to use checksums |
0ecb95affa9aade7d8e8a6c83c7e3b9537586f3f83aada4fd6a05e1871c5db91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.0 CPython/3.12.6
|