Predictive modeling · Python · AWS

AWS NYC 311 Service Resolution Modeling

A corrected, leakage-safe baseline for classifying whether a public service request will close within 72 hours.

The question

Can information available when a 311 request is created help distinguish requests that close within 72 hours from those that take longer?

Why the framing matters: the target is calculated from creation and closure timestamps, but closure information is never used as a model feature.

Data and scope

The final workflow uses 49,999 valid, closed NYC 311 records. It checks timestamp order, removes unusable rows, derives the 72-hour target, and documents the final class distribution.

What I built

  1. Python preparation and validation for timestamps, missing values, and categorical inputs.
  2. A preprocessing pipeline with one-hot encoding and a logistic-regression baseline.
  3. A train/test evaluation workflow with metrics beyond headline accuracy.
  4. A documented AWS path using S3 and Athena SQL, plus reproducible local instructions.

Results

The corrected model materially outperformed the majority-class benchmark and retained strong discrimination across classification thresholds.

ROC curve for the NYC 311 service-resolution model
The ROC curve traces sensitivity against false-positive rate across classification thresholds; the saved probabilities produce an 88.30% ROC AUC.
Confusion matrix for the NYC 311 service-resolution model
The confusion matrix shows all 10,000 test-set outcomes, making correct classifications and error types visible.
MetricTest-set result
Accuracy78.71%
Balanced accuracy79.88%
Precision88.60%
Recall73.68%
F1 score80.46%
ROC AUC88.30%
Majority-class benchmark59.47%

Validation

Six automated checks cover the target definition, timestamp logic, train/test separation, row counts, feature leakage, and metric generation. The repository also records the target bug found in the earlier version: weekday was mistakenly used as the response variable.

One limitation and the next test

The baseline is trained on closed historical requests. Before operational use, I would run time-based validation and monitor calibration and drift by agency, complaint type, borough, and season.