Automatidata Project

NYC Taxi
Fare Prediction

Machine Learning & Business Intelligence Case Study

Python Random Forest Feature Engineering Anomaly Detection Power BI Tableau
0.974
Random Forest R²
0.43
MAE (dollars)
1.71
RMSE (dollars)
2
BI Dashboards
NYC
TLC Trip Data

Project Overview

NYC taxi passengers lack fare transparency before starting a ride. Fare variability driven by distance, duration, traffic, and data anomalies creates uncertainty for riders and operational challenges for pricing systems.

This project builds an end-to-end analytics pipeline — from anomaly detection and feature engineering to a production-grade Random Forest model and dual BI dashboards — to predict fares accurately and support data-driven operational decisions.

Dataset

NYC TLC historical trip records — distance, tolls, duration, passenger count, payment type

Tools Used

Python · Random Forest · Feature Engineering · Power BI · Tableau

Best Result

Random Forest R²: 0.974,

MAE: $0.43, and RMSE: $1.71

on held-out test data

Business Value

Upfront pricing for long trips, anomaly detection QC rules, peak-hour operational insights

Dataset & Features

NYC Taxi & Limousine Commission historical trip records capturing ride-level fare, distance, duration, and payment behaviour — with significant data quality challenges requiring anomaly detection before modelling.

Key Features

Trip distance & duration Passenger count Payment type Tolls & surcharges Fare-per-mile engineered feature Peak-hour time indicators

Data Challenges

Unrealistic fares & zero-distance trips Fare anomalies skewing model training Non-linear distance/duration relationships High variance on 20+ mile long trips

Anomaly detection using fare-per-mile and duration logic was applied before modeling. OLS regression was used as a diagnostic validation step to assess feature significance.

Modeling & Statistical Validation

Random Forest Regression was selected after linear models failed variance and residual diagnostics — non-linear patterns in fare behaviour required a tree-based approach. OLS was used only as a diagnostic validation step.

Modeling Approach

1

Conducted Exploratory Data Analysis to validate pricing behavior and understand fare distribution patterns.

2

Applied anomaly detection using fare-per-mile and duration logic to remove unrealistic records before training.

3

Engineered features including fare-per-mile ratio and peak-hour indicators to improve model stability.

4

Used OLS regression as a diagnostic validation step to confirm feature significance before tree-based modelling.

5

Trained and evaluated Random Forest Regression — achieving R² 0.974, MAE $0.43, and RMSE $1.71 on test data.

Models Compared

Winner row highlighted — XGBoost selected as final production model.

Model Role R² RMSE Notes
Linear Regression Baseline — — Failed variance & residual diagnostics
Random Forest Regression Best Final production model 0.974 $1.71 Captures non-linear fare patterns; production-ready

Model Performance

Final model evaluation on held-out test data.

0.974
R² Score
Random Forest
$0.43
MAE
Random Forest
$1.71
RMSE
Random Forest
Failed
Linear Baseline
Diagnostics failed
Actual vs Predicted
Actual vs Predicted Fares
Model Performance Comparison
Model Performance Comparison

Interactive Power BI Analytics

Power BI dashboards surface fare behaviour patterns, error diagnostics, decomposition trees, and executive insights — enabling operational teams to understand pricing drivers and anomalies interactively.

Fare behavior & anomaly analysis Error diagnostics & decomposition trees Peak-hour operational patterns Executive insight tooltips
Power BI Overview Dashboard
Overview Dashboard
Deep Dive Dashboard
Deep Dive Analysis
Key Insights Dashboard
Key Insights
Tooltip Dashboard
Interactive Tooltips

Tableau – Model Validation

Tableau was used to validate the Random Forest model on unseen test data — comparing actual vs predicted fare trends, checking distribution alignment, and verifying error variance across trip segments.

Tableau Key Details
Key Details Dashboard
Tableau Model Evaluation
Model Evaluation Dashboard

Key Insights

Findings from EDA, model outputs, and dashboard exploration that inform investment decision-making.

Data quality directly determines model reliability — anomaly removal was the single most impactful preprocessing step.

Non-linear models significantly outperform linear regression for real-world fare prediction.

Long-distance trips (20+ miles) contribute the highest prediction errors and fare variance.

High-fare rides show more prediction variance — upfront pricing would reduce uncertainty for riders.

Duration & distance are the dominant fare uncertainty drivers across all trip segments.

Credit card payments dominate and include almost all tipping behaviour — cash trips underreport true revenue.

Business Recommendations

Actionable strategies for investors and decision-makers based on model outputs and dashboard analysis.

Investment Strategy Recommendations

Apply these to acquisition screening and portfolio decisions.

1

Promote credit card payments to capture tipping behaviour and improve driver earnings reporting.

2

Implement QC anomaly detection rules (fare, distance, duration thresholds) to clean future data automatically.

3

Introduce upfront pricing for 20+ mile trips to reduce fare uncertainty for both riders and drivers.

4

Strengthen peak-hour operations (morning & evening rush) — highest demand and revenue concentration.

5

Target medium-fare riders ($20–$60) for loyalty and repeat ride campaigns — most predictable segment.

6

Deploy dashboards as a weekly operational review tool for fleet management and pricing decisions.

Expected outcome: Improved fare transparency, reduced anomalies, higher driver earnings, and better peak-hour operational efficiency.