Skip to content

Wat-Street/agent-predictions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Agent-Based Economic Predictions

AI agents trained to model economic behaviors and predict interest rates in the U.S. economy using neural network policies and aggregation functions.


🚀 New to this project? → Start with QUICK_START_GUIDE.md

Choose your path:


Abstract

This project uses LLMs to emulate Person agents living across the United States, with each Person interacting with the Economy. Their interactions are based on their demographic characteristics and external stimuli. We train these agents using historical economic conditions, demographics, and interest rates to predict future economic indicators.

Architecture Overview

Economy

The Economy object provides an interface for Person agents to interact with and aggregates all interactions to predict interest rates.

Person Actions

Each Person can perform one of five economic actions:

  • Borrow - Take loans or credit
  • InvestSafe - Low-risk investments (bonds, savings)
  • InvestRisky - High-risk investments (stocks, crypto)
  • BuyLuxuryGoods - Non-essential purchases
  • DeclareBankruptcy - Financial insolvency

Activity Aggregation

We use a learned aggregator function A(action/person/tick) that processes all agent actions and returns a predicted interest rate. The model loss is computed against actual historical interest rates.

Person Agents

Each Person shares a single underlying policy P(demographic, stimuli) that:

  • Takes demographic information and economic stimuli as input
  • Outputs a probability distribution over the 5 possible actions
  • Uses very low temperature to simulate discrete action selection
  • Updates uniformly across all agents through backpropagation

Simulation Pipeline

  1. Encoding: Demographic and stimuli data for each Person is encoded
  2. Action Selection: Each Person computes an action vector using P(d, s)
  3. Aggregation: Action vectors (# of persons × # of ticks) are passed to aggregator A
  4. Prediction: A outputs a predicted interest rate
  5. Loss Computation: Prediction is compared to true historical interest rate
  6. Training: Backpropagation updates both P and A jointly

Model Architecture

Policy Network

class Policy(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc = nn.Sequential(
            nn.Linear(d_dim + s_dim, 64),
            nn.ReLU(),
            nn.Linear(64, 5)  # 5 possible actions
        )

    def forward(self, d, s):
        x = torch.cat([d, s], dim=-1)
        logits = self.fc(x)
        return F.gumbel_softmax(logits, 0.00001)

Aggregator Network

class Aggregator(nn.Module):
    def __init__(self, num_agents, ticks):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(5 * num_agents * ticks, 64),
            nn.ReLU(),
            nn.Linear(64, 1)
        )

    def forward(self, action_matrix):
        flat = action_matrix.view(1, -1)  # shape: (1, 5*num_agents*ticks)
        return self.net(flat)

Project Structure

agent-predictions/
├── README.md
├── requirements.txt
├── src/
│   ├── __init__.py
│   ├── models/
│   │   ├── __init__.py
│   │   ├── policy.py          # Policy neural network
│   │   └── aggregator.py      # Aggregator neural network
│   ├── agents/
│   │   ├── __init__.py
│   │   ├── person.py          # Person agent class
│   │   └── economy.py         # Economy environment
│   ├── data/
│   │   ├── __init__.py
│   │   ├── demographics.py    # Demographic data handling
│   │   └── economic_data.py   # Historical economic data
│   └── training/
│       ├── __init__.py
│       ├── trainer.py         # Training loop
│       └── simulation.py      # Simulation pipeline
├── data/
│   └── raw/                   # Raw economic and demographic data
├── experiments/
│   └── configs/               # Experiment configurations
└── tests/
    └── test_*.py             # Unit tests

Installation

git clone https://github.com/yourusername/agent-predictions.git
cd agent-predictions
pip install -r requirements.txt

Usage

from src.training.simulation import EconomicSimulation
from src.data.demographics import DemographicData
from src.data.economic_data import EconomicData

# Initialize simulation
sim = EconomicSimulation(
    num_agents=1000,
    num_ticks=100,
    demographic_data=DemographicData(),
    economic_data=EconomicData()
)

# Train the model
sim.train(epochs=100)

# Make predictions
predictions = sim.predict(test_demographics, test_stimuli)

Key Features

  • Multi-agent simulation with shared policy learning
  • Demographic-aware agent behavior modeling
  • Joint training of policy and aggregator networks
  • Historical data integration for realistic economic modeling
  • Scalable architecture supporting thousands of agents

Data Requirements

  • Historical interest rate data
  • U.S. demographic statistics
  • Economic indicators and stimuli data
  • Census and survey data for agent initialization

Project Planning & Management

📋 New to the project? Start here:

These documents provide a comprehensive 11-week roadmap for building this project with a team of 5-7 people.

Architecture Notes

Important: The original architecture had a critical issue where the model couldn't distinguish between different economic actions (Borrow vs InvestSafe, etc.). We recommend implementing the Aggregator with action embeddings to give each action semantic meaning. See PROJECT_MILESTONES.md Phase 2 for details.

Contributing

Please read our contributing guidelines and submit pull requests for any improvements.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Questions about this project? Contact @Krish Modi

About

AI agents trained to model past inflation rate in the U.S. economy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •