Skip to main content

Getting Started

Prerequisites

Before you begin, ensure you have:

  • Python installed on your system (Python 3.7+ is recommended)
  • pip (which comes with modern Python installations)
  • A basic understanding of Python and machine learning concepts

Installation

pi_optimal is now fully open source and available via PyPI. To install the package, simply run:

pip install pi_optimal

If you'd like to work directly with the source code or contribute, you can clone the repository and install dependencies using Poetry:

git clone https://github.com/pi-optimal/pi-optimal.git
cd pi-optimal
poetry install

Quick Start Example

Here's a minimal example to help you understand the basic workflow of pi_optimal:

import pandas as pd
import pi_optimal as po

# 1. Load your time-series data
data = pd.read_csv('your_data.csv')

# 2. Create a TimeseriesDataset
dataset = po.datasets.TimeseriesDataset(
data,
state_columns=['state_1', 'state_2'], # Your state variables
action_columns=['action'], # Your action variables
reward_column='reward', # Your reward metric
timestep_column='timestamp', # Time column
unit_index='id', # Unique identifier for each unit
lookback_timesteps=8 # Number of past steps to consider
)

# 3. Initialize and train an agent
agent = po.Agent()
agent.train(dataset=dataset)

# 4. Make predictions
predictions = agent.predict(new_data)

Key Components

  • TimeseriesDataset: Handles your time-series data and prepares it for the reinforcement learning (RL) pipeline.
  • Agent: The core component that trains on your data and makes predictions.
  • State Columns: Variables that describe your system's current state.
  • Action Columns: Variables that represent possible actions.
  • Reward Column: The metric you want to optimize.

Next Steps

  1. Explore the tutorials for detailed API references.
  2. Join our Slack community for help and discussions.
  3. Try implementing a simple use case with your own data.

Getting Help

If you run into issues:

  • Check our documentation.
  • Join our Slack community.
  • Open an issue on GitHub.
  • Review example notebooks for common patterns.