Predicting Uber trip mileage and cost using machine learning, with a full pipeline from raw trip logs to trained models and visualized results.
Course project for ICS474: Big Data Analytics, KFUPM (Fall 2024).
This project explores a real Uber trip dataset to answer three questions:
- Mileage prediction — how far will a trip go, based on its features?
- Cost estimation — what will a trip cost, using a distance-based formula?
- Data insights — what patterns and correlations show up in the data?
Two models are trained and compared: Linear Regression and Random Forest Regressor. The pipeline covers data preprocessing, feature engineering, model training, evaluation, and visualization end to end.
UberDataset.csv contains trip-level records, including:
- Start and end timestamps (
START_DATE,END_DATE) - Miles traveled (
MILES) - Trip purpose (
PURPOSE) - Categorical fields:
CATEGORY,START,STOP
Preprocessing steps:
- Fill missing
PURPOSEvalues withUnknown - Parse date columns to datetime and derive trip duration
- Drop rows with invalid or missing dates
- One-hot encode categorical variables
- Split into training (80%) and testing (20%) sets
- Standardize features with
StandardScaler
Random Forest Regressor:
| Metric | Value |
|---|---|
| MAE | 4.91 |
| MSE | 195.73 |
| RMSE | 13.99 |
| R² | 0.74 |
Visualizations produced by the notebook:
- Correlation heatmap — relationships between numeric and one-hot encoded features (e.g.
MILESvs. trip duration) - Predicted vs. actual cost scatter plot — accuracy of cost predictions against a perfect-prediction diagonal
- Log-scaled trip duration histogram — distribution of trip lengths
- Miles boxplot — outlier detection
Cost model: Cost = $0.50/mile + $2 base fare (a simple baseline — future work below covers refining it).
pandas
numpy
matplotlib
seaborn
scikit-learn
joblib
Install with:
pip install pandas numpy matplotlib seaborn scikit-learn joblib- Clone this repository.
- Make sure
UberDataset.csvis in the same directory as the notebook. - Open and run
ICS474proj.ipynb.
The notebook prints preprocessing logs, model evaluation metrics, and renders the visualizations described above.
- Add features like time of day or traffic conditions to the cost model
- Hyperparameter tuning via grid or randomized search
- Extend to multi-city Uber datasets for better generalization
ICS474proj.ipynb— full analysis notebook (preprocessing, modeling, evaluation, plots)UberDataset.csv— source datasetICS474 - Project.pdf— written project report
Built by Osama Al-Bahnasi.