A data science project analyzing Uber ride data to uncover patterns in ride demand, fare pricing, and peak hours, including a fare prediction model.
- Source: Uber Fares Dataset (Kaggle)
- Size: 200,000 rides (193,188 after cleaning)
- Features: pickup datetime, pickup/dropoff coordinates, fare amount, passenger count
uber-ride-analysis/
├── data/
│ ├── uber.csv # Raw dataset
│ └── uber_cleaned.csv # Cleaned dataset
├── visuals/ # All saved chart images
├── preprocessing.py # Data loading, cleaning, feature engineering
├── eda_visuals.py # 5 exploratory visualizations
├── fare_prediction.py # Regression model for fare prediction
├── tests.py # Automated data validation tests
├── main.py # Runs the full pipeline
└── README.md
- Removed unused ID columns (
Unnamed: 0,key) - Dropped rows with missing values
- Extracted
hour,day,month,year,day_of_weekfrom pickup datetime - Calculated trip distance using the Haversine formula (great-circle distance from GPS coordinates)
- Filtered unrealistic values: fares outside $0–200, distances outside 0–100km, passenger counts outside 1–6
- Bar plot — Rides by hour of day (peak hour identification)
- Line plot — Average fare trend across months
- Scatter plot — Trip distance vs fare amount
- Violin plot — Fare distribution across passenger counts
- Heatmap — Ride frequency by day of week vs hour
A Linear Regression model predicts fare_amount using distance, hour, passenger count, month, and day.
- Mean Absolute Error: $2.39
- R² Score: 0.725
- Most influential feature: trip distance (coefficient 2.19), far outweighing passenger count, month, hour, or day
- Peak ride hours are 6 PM – 10 PM on weekdays
- Weekend early mornings (12 AM – 3 AM) show unusually high demand compared to weekday early mornings
- Fare is driven almost entirely by distance, not passenger count
- The model performs well for typical short-to-mid trips but underestimates a small number of rare, high-fare outlier trips (likely long-distance/airport rides)
pip install pandas numpy matplotlib seaborn scikit-learn
python main.pyRun individual modules directly (python eda_visuals.py, python fare_prediction.py) to see chart pop-ups and model output interactively.
python tests.pyValidates: no negative fares, no negative distances, passenger count in valid range, no missing values.