Skip to content

Repository files navigation

Uber Ride Analysis

A data science project analyzing Uber ride data to uncover patterns in ride demand, fare pricing, and peak hours, including a fare prediction model.

Dataset

  • Source: Uber Fares Dataset (Kaggle)
  • Size: 200,000 rides (193,188 after cleaning)
  • Features: pickup datetime, pickup/dropoff coordinates, fare amount, passenger count

Project Structure

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

Data Preprocessing

  • Removed unused ID columns (Unnamed: 0, key)
  • Dropped rows with missing values
  • Extracted hour, day, month, year, day_of_week from 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

Visualizations

  1. Bar plot — Rides by hour of day (peak hour identification)
  2. Line plot — Average fare trend across months
  3. Scatter plot — Trip distance vs fare amount
  4. Violin plot — Fare distribution across passenger counts
  5. Heatmap — Ride frequency by day of week vs hour

Predictive Model

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

Key Insights

  • 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)

How to Run

pip install pandas numpy matplotlib seaborn scikit-learn
python main.py

Run individual modules directly (python eda_visuals.py, python fare_prediction.py) to see chart pop-ups and model output interactively.

Tests

python tests.py

Validates: no negative fares, no negative distances, passenger count in valid range, no missing values.

About

EDA and fare prediction model on 200K Uber rides, uncovers demand patterns, peak hours, and fare drivers

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages