Skip to content

A Reinforcement Learning agent built with Scikit-Learn and NumPy that optimizes product pricing strategies in competitive markets, achieving 28% revenue lift in simulations.

Notifications You must be signed in to change notification settings

T786-eng/ml-revenue-optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dynamic Price Optimization

A reinforcement learning project that demonstrates dynamic pricing strategy optimization using Q-learning with scikit-learn. The agent learns to set optimal prices in a simulated retail environment, considering factors like inventory levels, time remaining, and competitor pricing.

Features

  • Reinforcement Learning Agent: Implements Q-learning using scikit-learn's SGDRegressor for online learning
  • Pricing Environment Simulation: Models a retail scenario with inventory management, competitor reactions, and demand elasticity
  • Discrete Action Space: Agent selects from predefined price levels (40, 45, 50, 55, 60)
  • Performance Tracking: Logs training progress and calculates revenue improvement metrics
  • Visualization: Generates learning curve plots showing revenue optimization over training episodes

Installation

  1. Clone or download this repository
  2. Install the required dependencies:
pip install -r requirement.txt

Usage

Run the main script to train the agent and generate results:

python main.py

The script will:

  1. Train the reinforcement learning agent for 200 episodes
  2. Display performance metrics (initial vs. optimized revenue)
  3. Generate and save a visualization plot as pricing_strategy_results.png
  4. Show the learning curve with raw episode data and moving average

Results and Visualization

After training, the agent demonstrates significant revenue improvement. The generated plot (pricing_strategy_results.png) shows:

  • Raw episode revenue data (gray line)
  • 20-episode moving average (blue line) to illustrate learning progress
  • Clear upward trend as the agent optimizes pricing strategy

Example output:

--- Results for Resume ---
Average Revenue (Early Training): $XXXX.XX
Average Revenue (After Optimization): $XXXX.XX
Performance Lift: XX.X%

Dependencies

  • numpy>=1.24.0
  • pandas>=2.0.0
  • scikit-learn>=1.3.0
  • matplotlib>=3.7.0
  • seaborn>=0.12.0
  • joblib>=1.3.0
  • scipy>=1.10.0
  • tqdm>=4.65.0

How It Works

  1. Environment: Simulates 30-day retail period with inventory constraints and competitor price adjustments
  2. Agent: Uses Q-learning to estimate value of each price action in different states
  3. Learning: Updates Q-values using temporal difference learning with epsilon-greedy exploration
  4. Optimization: Balances immediate revenue against inventory management and competitor dynamics

The agent learns to adapt pricing based on remaining inventory, time pressure, and competitor behavior, resulting in optimized revenue generation.

📜 License This project is open-source and available under the MIT License.

About

A Reinforcement Learning agent built with Scikit-Learn and NumPy that optimizes product pricing strategies in competitive markets, achieving 28% revenue lift in simulations.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages