A modern web application that predicts taxi fares using machine learning models deployed with Django. The application features a beautiful, responsive UI and uses Ridge Regression and Decision Tree algorithms to provide accurate fare estimates.
- Multiple ML Models: Ridge Regression and Decision Tree for fare prediction
 - Modern UI: Beautiful, responsive interface with animations and gradients
 - Real-time Predictions: Instant fare calculations based on trip parameters
 - Mobile Responsive: Works seamlessly on all devices
 - Interactive Design: Smooth animations and user-friendly experience
 
- Backend: Django 4.x, Python 3.13
 - Frontend: HTML5, CSS3, JavaScript
 - Machine Learning: scikit-learn
 - Database: SQLite (default)
 - Styling: Custom CSS with modern animations and gradients
 
Before running this project, make sure you have:
- Python 3.8 or higher
 - pip (Python package installer)
 - Git
 
- 
Clone the repository
git clone https://github.com/malakasaber/Model-Deployment-using-Django.git cd Model-Deployment-using-Django - 
Create and activate virtual environment
# Windows python -m venv venv venv\Scripts\activate # macOS/Linux python -m venv venv source venv/bin/activate
 - 
Install dependencies
pip install django scikit-learn pandas numpy
 - 
Run database migrations
python manage.py migrate
 - 
Start the development server
python manage.py runserver
 - 
Open your browser Navigate to
http://127.0.0.1:8000/to see the application. 
- 
Fill in the form with the following trip details:
- Pickup and dropoff coordinates (longitude/latitude)
 - Passenger count
 - Distances to key locations (JFK, EWR, LGA airports, Statue of Liberty, NYC)
 - Trip distance and bearing
 
 - 
Click "Predict Fare" to get instant predictions
 - 
View results in the beautiful modal popup showing predictions from both models
 
DjangoTask/
├── deploymentproject/          # Django project settings
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   ├── wsgi.py
│   └── asgi.py
├── myapp/                      # Main Django app
│   ├── models/                 # Pre-trained ML models
│   │   ├── transformer.pkl
│   │   ├── transformer2.pkl
│   │   ├── XGB.pkl
│   │   ├── Linear.pkl
│   │   ├── KNN.pkl
│   │   ├── ridgeregression.pkl
│   │   └── decisiontree.pkl
│   ├── templates/myapp/        # HTML templates
│   │   └── index.html
│   ├── __init__.py
│   ├── admin.py
│   ├── apps.py
│   ├── ml_pipeline.py          # ML model loading and prediction logic
│   ├── models.py
│   ├── model2.py
│   ├── urls.py
│   ├── views.py
│   └── tests.py
├── db.sqlite3                  # SQLite database
├── manage.py                   # Django management script
└── README.md
- Purpose: Gradient boosting framework optimized for speed and performance
 - Strengths: High accuracy, handles missing data, effective on structured data
 - Use Case: Predicts fares with fine-grained performance tuning and scalability
 
- Purpose: Models linear relationship between input variables and output
 - Strengths: Fast, interpretable, works well with linearly correlated data
 - Use Case: Predicts fares based on distance when the relationship is linear
 
- Purpose: Instance-based learning model for classification and regression
 - Strengths: Simple, non-parametric, adapts well to local data structure
 - Use Case: Estimates fares by comparing with similar past trips
 
- Purpose: Linear regression with L2 regularization
 - Strengths: Good for handling multicollinearity, stable predictions
 - Use Case: Baseline model for fare prediction
 
- Purpose: Non-linear tree-based regression model
 - Strengths: Captures complex patterns, easy to interpret
 - Use Case: Handles non-linear relationships in fare calculation
 
The model uses the following 20 features for prediction:
| Feature | Description | 
|---|---|
pickup_longitude | 
Pickup location longitude | 
pickup_latitude | 
Pickup location latitude | 
dropoff_longitude | 
Dropoff location longitude | 
dropoff_latitude | 
Dropoff location latitude | 
passenger_count | 
Number of passengers | 
jfk_dist | 
Distance to JFK Airport | 
ewr_dist | 
Distance to Newark Airport | 
lga_dist | 
Distance to LaGuardia Airport | 
sol_dist | 
Distance to Statue of Liberty | 
nyc_dist | 
Distance to NYC center | 
distance | 
Trip distance | 
bearing | 
Direction of travel | 
- Modern Design: Gradient backgrounds and glassmorphism effects
 - Responsive Layout: Grid-based form layout that adapts to screen size
 - Interactive Elements: Hover effects, smooth transitions, and animations
 - Visual Feedback: Loading spinners, input validation, and success modals
 - Accessibility: Proper contrast ratios and semantic HTML
 
- Train your model and save it as a 
.pklfile - Place it in the 
myapp/models/directory - Update 
ml_pipeline.pyto load and use your model - Modify the view and template to display the new predictions
 
- Edit 
myapp/templates/myapp/index.htmlfor structure and styling - Modify CSS classes for different visual themes
 - Add new animations or interactive elements as needed
 
GET /- Main page with prediction formPOST /- Submit prediction request and get results
- Fork the repository
 - Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
 
This project is licensed under the MIT License - see the LICENSE file for details.
Malak Ahmed Saber
- GitHub: @malakasaber
 
Marawan Abbas
- Github: @MarwanAbbas205
 
- Built during Cellula Technologies Internship
 - Inspired by real-world taxi fare prediction systems
 - UI design influenced by modern web design trends
 
If you have any questions or run into issues, please:
- Check the existing issues on GitHub
 - Create a new issue with detailed information
 - Contact the maintainer