Skip to content

codetayto/dynamic-ride-pricing-system

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dynamic Ride Pricing System

License Python Flask Streamlit Machine Learning

Dynamic Pricing System for ride-hailing applications, using Machine Learning and multiple real-world factors to optimize ride prices in real-time.

📋 Overview

Dynamic Ride Pricing System demo

The system uses machine learning models to predict base prices based on ride characteristics and then applies dynamic (real-time) adjustments based on supply-demand, weather, time of day, user history, and many other factors.

Key Features:

  • Smart Pricing: Base price prediction based on distance, time, vehicle type
  • 🌦️ Real-time Factors: Price adjustments based on weather, traffic congestion, supply-demand
  • 🚀 API Integration: RESTful API for real-world applications
  • 📊 Analytics: Visual dashboard for analysis and simulation

🛠️ Installation

Click to expand installation steps
  1. Clone repository:
git clone https://github.com/yourusername/dynamic-ride-pricing.git
cd dynamic-ride-pricing
  1. Install libraries:
pip install -r requirements.txt
  1. Train the model:
python main.py
  1. Run API server:
python -m api.app
  1. Run dashboard:
streamlit run dashboard/app.py

🖥️ Usage

🔌 API

API runs at http://localhost:5001/api with the following endpoints:

Endpoint Method Description
/health GET Check operational status
/get-price POST Calculate ride price based on parameters
/simulate-rides GET Simulate multiple rides with random parameters
/pricing-factors GET View factors affecting price

📈 Dashboard

The Streamlit dashboard provides:

  1. Multiple Ride Simulation:

    • 🚕 Create multiple random rides
    • 📊 Analyze and visualize results
  2. Parameter-based Simulation:

    • 🎛️ Manually adjust ride parameters
    • 🔍 View detailed pricing analysis

📂 Project Structure

Click to expand project structure
dynamic-pricing/
│
├── api/                        # API server module
│   ├── __init__.py
│   └── app.py                  # Flask API server
│
├── dashboard/                  # Streamlit Dashboard
│   └── app.py                  # Dashboard application
│
├── data/                       # Data processing module
│   ├── __init__.py
│   ├── data_generator.py       # Sample data generator
│   └── preprocessor.py         # Data preprocessing
│
├── models/                     # ML model module
│   ├── __init__.py
│   └── pricing_model.py        # Price prediction model
│
├── pricing/                    # Dynamic Pricing module
│   ├── __init__.py
│   └── dynamic_pricer.py       # Dynamic pricing algorithm
│
├── utils/                      # Utilities
│   ├── __init__.py
│   └── geo_utils.py            # Geographic/distance utilities
│
├── main.py                     # Main execution file
├── requirements.txt            # Required libraries
└── README.md                   # This file

💼 Dynamic Pricing Mechanism

The system uses a 2-step process to determine prices:

1️⃣ Base Price Prediction

Uses Random Forest model to predict price from distance, time, vehicle type. Result is the base price for the ride.

2️⃣ Dynamic Price Adjustments

Factor Description Impact
🚗 Supply-Demand Adjusts price based on driver availability and area demand ±15%
🌧️ Weather Increases price during adverse weather conditions +5-10%
🚦 Congestion Adjusts price according to traffic congestion levels +3-12%
🏆 Customer Loyalty Discounts for loyal users -5-15%

📊 Example Results

Example results from the pricing system for a 5km ride:
- Base price: 75,000 VND
- Optimized price: 82,500 VND
- Price change %: +10.0%

Insights:
- Price increased by 10.0% compared to base price due to high demand during peak hours
- Area has low supply-demand ratio (8 drivers/45 requests)
- Weather conditions (rain) increased price by 5%

🔧 System Requirements

  • 🐍 Python 3.9+
  • 💾 4GB RAM (recommended)
  • 💽 50MB disk space

📄 License

MIT License


Repository Setup Instructions

Place this README.md file in the root directory of the project (same level as main.py).

To add this file to the repository, do the following:

  1. Create a file named README.md in the root directory of the project
  2. Copy the above content into the file
  3. Save the file and add it to the git repository:
git add README.md
git commit -m "Add project README"
git push

About

Dynamic Pricing System for ride-hailing applications, using Machine Learning and multiple real-world factors to optimize ride prices in real-time.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%