β If you find this workforce analytics case study or the Streamlit simulator helpful, please consider starring this repository!
An end-to-end data analytics and workforce intelligence case study examining 90 days of employee attendance, punctuality dynamics, commute friction, and day-of-week behavioral patterns across 50 employees and 3,550 recorded shifts.
Features an executive Streamlit HR policy simulator demonstrating that a 15-minute flexible grace window reduces tardiness by 67.8% across departments, and a flagship XGBoost predictive classifier forecasting severe late arrivals with ROC-AUC = 0.908.
Modern enterprise HR leaders face significant productivity friction due to inflexible attendance expectations and transit bottlenecks. This project applies statistical modeling, time-series aggregation, exploratory data analysis (EDA), and machine learning to uncover operational bottlenecks and guide evidence-based workforce scheduling policies.
- Total Shifts Analyzed: 3,550 across 50 employees and 5 departments.
- Strict 9:00 AM Tardiness: 40.5% (1,436 shifts logged as late).
- Severe Tardiness (>15 mins): 13.0% (462 shifts).
- Minor Delay Absorption: 67.8% of late shifts fall within a 1β15 minute micro-delay window (morning signals, elevator queues).
- Policy Simulation Impact: Shifting scheduled start from 9:00 AM to 9:30 AM (or adopting a 15m grace window) reduces tardiness by 67.8% across all departments.
- Predictive Model ROC-AUC: 0.9040 on test split (0.8821 Β± 0.0166 on 5-fold CV with 0% data leakage).
An interactive executive workforce intelligence dashboard that allows HR managers to simulate policy changes and test real-time ML risk predictions:
- π Custom Biometric / Punch CSV Uploader: Upload any organization's raw punch logs or use the pre-calibrated 90-day dataset.
- Executive Shift Start & Grace Window Simulator: Adjust shift start timing (9:00 AM β‘οΈ 9:30 AM) and grace periods (0m to 30m) with live impact calculations and an Exportable Executive Policy Impact Memo (.md).
- Individual Late-Arrival Risk Forecaster: Input department, commute distance (km), day of week, punch method, and employee baseline reliability to predict late-arrival probability with prescriptive HR recommendations.
- π Local Factor Explainability Breakdown: Bar chart breakdown quantifying individual risk factors (commute distance delta, Monday peak choke, department exposure, and baseline profile).
- π€ Employee 360Β° Profile Studio: Deep-dive into an individual employee's 90-day attendance record, punctuality score, day-of-week late patterns, and activity logs.
- Model Benchmark & Explainability Studio: Inspect cross-validation metrics, ROC curves, feature importance gain hierarchies, and confusion matrices.
- Raw Data Explorer: Filterable shift table with dynamic CSV export.
Launch the dashboard:
streamlit run streamlit_app.pyRun automated tests:
python -m unittest tests/test_pipeline.pyDeploy with Docker:
docker build -t attendance-analytics .
docker run -p 8501:8501 attendance-analyticsWe benchmarked three classification architectures using a 5-Fold Stratified Cross-Validation protocol (strictly leak-free with train-fold target encoding) to predict severe late arrivals (>15 minutes):
| Model Architecture | 5-Fold CV ROC-AUC | Test ROC-AUC | Test Accuracy | Test Precision | Test Recall | Test F1-Score |
|---|---|---|---|---|---|---|
| Logistic Regression | 0.8901 Β± 0.0162 | 0.9073 | 91.3% | 72.7% | 52.2% | 0.6076 |
| Random Forest (150 Trees) | 0.8865 Β± 0.0158 | 0.9034 | 90.7% | 78.3% | 39.1% | 0.5217 |
| XGBoost (Flagship Classifier) | 0.8821 Β± 0.0166 | 0.9040 | 91.3% | 84.1% | 40.2% | 0.5441 |
-
Commute Distance (
$40.8%$ Gain): Urban transit distance along Ahmedabad's SG Highway and SP Ring Road is the single strongest predictor of morning arrival volatility. -
Commute Distance Γ Monday Interaction (
$24.6%$ Gain): Peak morning congestion on Mondays introduces severe non-linear transit delays for employees commuting$>18\text{ km}$ . -
Department Structural Factor (
$14.2%$ Gain): Field-heavy departments (Sales and Operations) face higher external transit exposure compared to Engineering and HR.
Cross-model comparison demonstrating strong discrimination ability (
Commute distance and the Monday transit choke interaction dominate the split gain, proving that tardiness is systematically structural rather than purely behavioral.
Evaluates classification performance at the 0.50 probability threshold, correctly isolating on-time and minor friction from severe operational delays.
Demonstrates the dramatic reduction in tardiness across all five departments when transitioning from a rigid 9:00 AM policy to a 15-minute flexible arrival buffer.
-
Implement a 15-Minute Flexible Grace Window:
- Over 67.8% of recorded "late" punches occur within 15 minutes of shift start. Adopting a flexible core-hours band (09:15 AM to 09:45 AM arrival with matched checkout) immediately recovers lost morale and administrative overhead while maintaining 8.5-hour productivity.
-
Stagger Monday Morning Standups Past 10:00 AM:
- Monday traffic bottlenecks create an odds ratio of
$+3.4\times$ severe delay for staff commuting$>18\text{ km}$ . Scheduling team standups after 10:00 AM guarantees 100% participation.
- Monday traffic bottlenecks create an odds ratio of
-
Route-Optimized Shuttle or Transit Subsidy for Commuters
$>20\text{ km}$ :- Employees in the
$>20\text{ km}$ bracket represent 74% of all severe late hours. Subsidizing transit corridors directly recoups organizational capacity.
- Employees in the
attendance-data-analytics/
βββ data/
β βββ attendance_90days_synthetic.csv # 3,550 calibrated shift records (MayβJuly 2026)
βββ figures/ # Exported publication figures (300 DPI)
β βββ model_roc_curve.png # Comparison ROC-AUC curves
β βββ model_feature_importance.png # XGBoost feature importance hierarchy
β βββ model_confusion_matrix.png # Test split confusion matrix
β βββ policy_tardiness_reduction.png # Before vs After departmental bar chart
β βββ dept_punctuality_breakdown.png # Departmental attendance composition
β βββ daily_attendance_trend.png # 90-day active headcount trend
β βββ checkin_distribution.png # Arrival timestamp distribution
β βββ day_of_week_comparison.png # Monday vs weekday tardiness
β βββ commute_distance_vs_tardiness.png # Commute distance scatter correlation
βββ models/
β βββ late_arrival_pipeline.joblib # Serialized XGBoost pipeline bundle
β βββ model_metrics.json # Benchmark cross-validation metrics
βββ generate_dataset.py # Calibrated synthetic data generator (seed: 42)
βββ train_late_arrival_model.py # ML training pipeline, evaluation & figure export
βββ streamlit_app.py # Interactive executive HR policy simulator
βββ analyze_attendance.py # Statistical EDA script
βββ attendance_analytics.ipynb # Interactive Jupyter analysis notebook
βββ requirements.txt # Project dependencies
βββ CHANGELOG_EXPLAINED.md # Simple interview walkthrough
βββ README.md # Documentation & architecture guide
git clone https://github.com/prachizala/attendance-data-analytics.git
cd attendance-data-analyticspython -m venv .venv
# Windows:
.\.venv\Scripts\activate
# macOS / Linux:
source .venv/bin/activate
pip install -r requirements.txtpython -m unittest tests/test_pipeline.pystreamlit run streamlit_app.py# Generate synthetic dataset (3,550 shifts, seed 42)
python generate_dataset.py
# Train ML classifiers, benchmark CV metrics, and export figures
python train_late_arrival_model.py| Parameter | Specification | Details |
|---|---|---|
| Python Runtime | Python 3.10 / 3.11 | Validated on Python 3.10 & 3.11 |
| Operating Systems | Windows 10/11, macOS, Ubuntu 22.04+ | Cross-platform compatible |
| Primary Frameworks | Streamlit 1.30+, Scikit-Learn 1.3+, XGBoost 2.0+ | Machine learning & web dashboard |
| Data Processing | Pandas 2.x, NumPy 1.24+ | Vectorized tabular operations |
| Visualizations | Matplotlib 3.7+, Seaborn 0.12+, Altair 5.0+ | Static & interactive charting |
| Testing Framework | unittest (Standard Library) |
Automated test suite in tests/ |
| CI/CD | GitHub Actions | Automated build & test matrix on Python 3.10 & 3.11 |
| Containerization | Docker (Python 3.11-slim) | Standalone deployment on port 8501 |
This project is open-source under the MIT License.



