Skip to content

A neural network study project using PyTorch to predict delivery time and pricing based on distance. Educational project simulating food delivery platforms with linear regression models and data visualization.

Notifications You must be signed in to change notification settings

Jpzinn654/DeliveryPredictAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Delivery Predict AI - Neural Network Study Project

Python PyTorch License Status

A neural network study project for delivery time and price prediction

📋 Overview

Delivery Predict AI is an educational machine learning project developed to explore neural network fundamentals using PyTorch. The project simulates a delivery prediction system similar to existing food delivery platforms like iFood, focusing on predicting delivery time and cost based on distance.

This project serves as a study case for understanding:

  • Linear regression with neural networks
  • PyTorch fundamentals and training pipelines
  • Multi-output prediction models
  • Data visualization for ML models

⚠️ Disclaimer: This is an educational project, not a production-ready system. The models and data are simplified for learning purposes.

🎯 Project Objectives

  • Study neural network implementation using PyTorch
  • Understand linear regression for predictive analytics
  • Explore multi-output prediction scenarios
  • Create visualizations for model performance analysis
  • Practice software architecture for ML projects

🏗️ Project Structure

├── 📁 src
│ ├── 📁 data
│ │ └── 🐍 dataset.py # Sample delivery dataset
│ ├── 📁 model
│ │ └── 🐍 model.py # Neural network architectures
│ ├── 📁 utils
│ │ └── 🐍 graph_helper.py # Visualization utilities
│ └── 🐍 main.py # Main training and evaluation script
├── ⚙️ .gitignore
├── 📄 poetry.lock # Poetry dependency lock file
├── ⚙️ pyproject.toml # Project configuration and dependencies
└── 📝 README.md # This file

🧠 Model Architecture

The project implements two separate linear regression models:

1. Time Prediction Model

  • Input: Distance (kilometers)
  • Output: Estimated delivery time (minutes)
  • Architecture: Single linear layer (nn.Linear(1, 1))

2. Price Prediction Model

  • Input: Distance (kilometers)
  • Output: Estimated delivery price (Brazilian Reais - R$)
  • Architecture: Single linear layer (nn.Linear(1, 1))

Training Parameters:

  • Loss Function: Mean Squared Error (MSE)
  • Optimizer: Stochastic Gradient Descent (SGD)
  • Learning Rate: 0.01
  • Epochs: 1000

📊 Dataset

The synthetic dataset simulates delivery metrics for a Honda CG 160 motorcycle:

Distance (km) Time (minutes) Price per km (R$/km)
1.0 1.2 0.50
2.0 2.4 1.00
3.0 3.6 1.50
4.0 4.8 2.00
5.0 6.0 2.50
6.0 7.2 3.00
7.0 8.4 3.50
8.0 9.6 4.00
9.0 10.8 4.50
10.0 12.0 5.00

Dataset characteristics for study:

  • Linear relationships: Both time and price per km increase linearly with distance
  • Time calculation: Based on average speed of 50 km/h → time = (distance / 50) * 60
  • Price progression: Price per km increases from R$ 0.50 to R$ 5.00 linearly
  • Total price: Can be calculated as total_price = price_per_km × distance

🚀 Getting Started

Prerequisites

  • Python 3.8 or higher
  • Poetry (dependency management)

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/delivery-predict-ai.git
    cd delivery-predict-ai
  2. Install dependencies using Poetry:

    poetry install
  3. Activate the virtual environment

    poetry shell

📈 Visualizations

The project generates two main visualizations:

  1. delivery_analysis.png - Dual plot showing:

    • Distance vs Time prediction
    • Distance vs Price prediction with R$/km overlay
  2. price_per_km_analysis.png - Detailed analysis:

    • Price per kilometer across distance range
    • Comparison against target rate (R$ 2.40/km)

🧪 Example Usage

After training, the model can make predictions:

# Example: Predict for 3.5 km
distance = torch.tensor([[3.5]])
time_pred = time_model(distance)      # Estimated time
price_pred = price_model(distance)    # Estimated price

Dependencies

Core dependencies (managed by Poetry):

  • torch>=2.0.0: Deep learning framework
  • matplotlib>=3.7.0: Data visualization
  • numpy>=1.24.0: Numerical computations

🎓 Learning Outcomes

This project demonstrates:

PyTorch Fundamentals

  • Tensor operations and autograd
  • Neural network module creation
  • Training loop implementation

ML Concepts

  • Linear regression as neural networks
  • Loss functions and optimization
  • Model evaluation metrics

Software Engineering

  • Modular project structure
  • Code documentation standards
  • Visualization integration

🙏 Acknowledgments

  • Inspired by real-world delivery platforms like iFood
  • Built for educational purposes in neural network studies
  • Thanks to the PyTorch community for excellent documentation

Built for learning • Powered by PyTorch • Inspired by real-world applications

Note: This project simulates delivery prediction for educational purposes only. Actual delivery platforms use more complex models and real-time data.

About

A neural network study project using PyTorch to predict delivery time and pricing based on distance. Educational project simulating food delivery platforms with linear regression models and data visualization.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages