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.
- 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
├── 📁 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
The project implements two separate linear regression models:
- Input: Distance (kilometers)
- Output: Estimated delivery time (minutes)
- Architecture: Single linear layer (
nn.Linear(1, 1))
- 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
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
- Python 3.8 or higher
- Poetry (dependency management)
-
Clone the repository:
git clone https://github.com/yourusername/delivery-predict-ai.git cd delivery-predict-ai -
Install dependencies using Poetry:
poetry install
-
Activate the virtual environment
poetry shell
The project generates two main visualizations:
-
delivery_analysis.png- Dual plot showing:- Distance vs Time prediction
- Distance vs Price prediction with R$/km overlay
-
price_per_km_analysis.png- Detailed analysis:- Price per kilometer across distance range
- Comparison against target rate (R$ 2.40/km)
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 priceCore dependencies (managed by Poetry):
torch>=2.0.0: Deep learning frameworkmatplotlib>=3.7.0: Data visualizationnumpy>=1.24.0: Numerical computations
This project demonstrates:
- Tensor operations and autograd
- Neural network module creation
- Training loop implementation
- Linear regression as neural networks
- Loss functions and optimization
- Model evaluation metrics
- Modular project structure
- Code documentation standards
- Visualization integration
- 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.