Skip to main content

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.

PyPI version Tutorial


Key Features

  • Policy gradient-based reinforcement learning for time series prediction
  • Easy integration with existing PyTorch workflows
  • Support for custom time series datasets
  • Built-in state normalization and reward calculation
  • Flexible neural network architecture configuration
  • Real-time prediction capabilities

Installation

pip install -i https://test.pypi.org/simple/ timeseries-agent
pip install lightning torch

Getting Started

The easiest way to get started is by following our Colab Tutorial, which walks through a complete example of training and testing a time series agent.

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 with at least one target column.
import pandas as pd
from timeseries_agent import RLTimeSeriesDataset, 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
NUM_FEATURES = data_df.shape[1]  # Number of features in dataset

# 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

License

TimeSeries Agent is released under the MIT 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.23-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for timeseries_agent-0.0.23-py3-none-any.whl
Algorithm Hash digest
SHA256 a7397ea28272f340e40bade70285e9994b3a54cd8f69c965f8bac75fbe2f6962
MD5 9db1c0367cbf29932dc6c337541dba56
BLAKE2b-256 378ceebf685ccdee095fd951586b5f2cc707259e2ae799387f297e22839129e8

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