How sanjayt2706/driverbehaviorproject works
DriverRisk is a smartphone-based driving behavior and trip-risk analysis project. The intended user workflow is to collect GPS and IMU data during a trip, retain it locally, upload/process it through the backend, and inspect trip-level risk results. The backend’s documented processing stages include cleaning, windowing, feature extraction, road geometry, and curve density; the repository also contains a separate model-training workflow. The Dashboard directory described in the README is absent from the supplied tree, and the Android home screen currently does not start recording. Some backend route and inference wiring is therefore left unspecified.
Main entry points: pipeline.py Processing pipeline · TripRecordingService.kt Recording service · step05_split_scale.py Split and scale · step08_evaluate.py Evaluate models
Components 32
Android collection
- Home UI
Android/app/src/main/java/com/driverisk/app/ui/home/HomeFragment.kt - Recording service
Android/app/src/main/java/com/driverisk/app/service/TripRecordingService.kt - GPS collector
Android/app/src/main/java/com/driverisk/app/sensors/LocationCollector.kt - IMU collector
Android/app/src/main/java/com/driverisk/app/sensors/SensorCollector.kt - Trip detector
Android/app/src/main/java/com/driverisk/app/sensors/TripDetector.kt - Trip repository
Android/app/src/main/java/com/driverisk/app/data/repository/TripRepository.kt - Local trip store
Android/app/src/main/java/com/driverisk/app/data/local/DriveRiskDatabase.kt
Backend processing
- Trip API
Backend/app/api/routes/trips.py - Processing pipeline
Backend/app/processing/pipeline.py - Clean samples
Backend/app/processing/preprocessing.py - Window samples
Backend/app/processing/windowing.py - Extract features
Backend/app/processing/features.py - Road geometry
Backend/app/processing/road_geometry.py - Curve density
Backend/app/processing/curve_density.py - Backend database
Backend/app/database.py
Model inference
- Risk predictor
Backend/app/ml/predictor.py - Model wrapper
Backend/app/ml/model_wrapper.py - SHAP explainer
Backend/app/explain/shap_explainer.py - Risk explanation
Backend/app/explain/reason_text.py
Model training
- Load raw data
ML/src/step01_load_raw.py - Clean data
ML/src/step02_clean.py - Label samples
ML/src/step03_label.py - Build features
ML/src/step04_build_features.py - Split and scale
ML/src/step05_split_scale.py - Train Random Forest
ML/src/step06_train_rf.py - Train XGBoost
ML/src/step07_train_xgb.py - Evaluate models
ML/src/step08_evaluate.py - Select model
ML/src/step09_select_best.py - Global SHAP
ML/src/step10_global_shap.py
Other components
- Driver
- UAH-DriveSet
- Analytics dashboard
Connections 28
- Driver → Home UI: uses
- Home UI → Recording service: start intent
- Recording service → GPS collector: collects GPS
- Recording service → IMU collector: collects IMU
- Recording service → Trip detector: checks speed
- Recording service → Trip repository: persists trip
- Trip repository → Local trip store: reads and writes
- Trip API → Processing pipeline: processes trip
- Processing pipeline → Clean samples: cleans
- Processing pipeline → Window samples: creates windows
- Processing pipeline → Extract features: extracts features
- Processing pipeline → Road geometry: extracts geometry
- Processing pipeline → Curve density: enriches curves
- Trip API → Backend database: stores trip data
- Risk predictor → Model wrapper: predicts with
- SHAP explainer → Risk explanation: formats reasons
- UAH-DriveSet → Load raw data: loads
- Load raw data → Clean data: cleans
- Clean data → Label samples: labels
- Label samples → Build features: constructs features
- Build features → Split and scale: splits and scales
- Split and scale → Train Random Forest: trains
- Split and scale → Train XGBoost: trains
- Train Random Forest → Evaluate models: evaluates
- Train XGBoost → Evaluate models: evaluates
- Evaluate models → Select model: selects best
- Select model → Global SHAP: explains model
- Backend database → Analytics dashboard: visualizes results