Skip to main content

A Policy Gradient RL agent for time series prediction using PyTorch Lightning.

Project description

TimeSeries Agent


PyPI version PyPI Downloads Basic Tutorial Tuner Tutorial Genetic Tuner Tutorial

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.


Key Features

  • Policy gradient-based reinforcement learning for time series prediction
  • 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 (and activation function)
  • Real-time prediction capabilities

Installation

You can install TimeSeries Agent using pip:

pip install timeseries-agent

Getting Started

We provide two interactive Colab tutorials to help you get started:

  1. Basic Tutorial - Walks through a complete example of training and testing a time series agent.
  2. Tuner Tutorial - Shows how to use the ModelTuner to find optimal hyperparameters for your agent.
  3. Genetic Tuner Tutorial - Shows how to use the GeneticTuner to find optimal hyperparameters for your agent. The genetic tuner uses evolutionary algorithms with diversity scoring and simulated annealing to efficiently explore the parameter space.

Using Your Own Data

To use TimeSeries Agent with your own data, you need to:

  1. Prepare your time series data as a pandas DataFrame.
import pandas as pd
from timeseries_agent import SequentialTimeSeriesDataset, PolicyGradientAgent

# Load your time series data
data_df = pd.DataFrame({
    'value': your_target_values,
    'feature1': your_feature1_values,
    'feature2': your_feature2_values,
    # ... add more features as needed
})

# Configure the RL environment
LOOKBACK = 7                       # Number of past time steps to consider
TARGET_COLUMN = 'value'            # Column for reward calculation

# Create and train the agent
agent = PolicyGradientAgent(
    full_data=data_df,
    target_column=TARGET_COLUMN,
    input_features=NUM_FEATURES,
    lookback=LOOKBACK,
    hidden_layers=[100, 100, 10],  # Customize network architecture
    normalize_state=True           # Enable state normalization
)

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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

timeseries_agent-0.0.29-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

Details for the file timeseries_agent-0.0.29-py3-none-any.whl.

File metadata

File hashes

Hashes for timeseries_agent-0.0.29-py3-none-any.whl
Algorithm Hash digest
SHA256 ddd1f18c2116fe264a51190f0878cabbbc2ba1c2d89e9559b9aa85e7d8331384
MD5 c771138ed0ef04409c629e33557e64e3
BLAKE2b-256 0449df4857d02651ebad1d7c58fe0df2e9b81c881f4518c768fd48cb1685de81

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