Construction Safety Dataset (CSDataset)
- CSDataset is a comprehensive multi-level construction safety dataset comprising linked OSHA incident, inspection, and violation records from 2013 to 2022.
- Its detailed schema supports robust ML and LLM applications through structured feature engineering, narrative analysis, and causal inference studies.
- Baseline implementations demonstrate high performance in incident severity classification and violation prediction using traditional ML classifiers and language models.
The Construction Safety Dataset (CSDataset) is a comprehensive, large-scale, multi-level resource for construction site safety research, designed to enable robust analytics, benchmarking, and methodological advances in accident prediction, risk assessment, and policy evaluation. CSDataset uniquely integrates structured and unstructured data across incident, inspection, and violation records sourced from the U.S. Occupational Safety and Health Administration (OSHA) over a ten-year period, facilitating a wide range of ML and LLM applications (Ou et al., 9 Aug 2025).
1. Dataset Composition and Sources
CSDataset consists of three interlinked data strata, each representing a distinct operational level in construction safety documentation:
- Incident Level: ~52,000 records of onsite accidents (2013–2022), each detailing severity, event type, location, worker role, and rich narratives.
- Inspection Level: ~76,000 inspection records containing details of regulatory site visits, complaint types, outcomes, and inspector notes.
- Violation Level: ~61,000 violation entries linked to inspections, specifying regulatory codes, penalty amounts, violation types, and narrative descriptions.
All records are derived from public OSHA data, spanning January 2013 to December 2022. Cross-referencing and temporal linkage are provided via the fields activity_nr (incident-inspection join), inspection_id (inspection-violation join), and violator_id. This schema supports longitudinal and causal analysis by aligning events and compliance actions within a 90-day temporal window.
2. Data Schema, Feature Engineering, and Preprocessing
Each level in CSDataset features distinct attributes. High-level schema design aligns with standard pandas types:
- Incident Level: Features include
incident_id,activity_nr, U.S. geospatial identifiers,event_date,event_type(≈20 categories),degree_of_inj_x(severity: 0–4),weather,job_title(~200 possible values), and free-text narrative fields (abstract, average ≈150 words). - Inspection Level: Fields such as
inspection_id,activity_nr,inspection_date,complaint_type,inspection_result, and inspector information, along with textualnotes. - Violation Level:
violation_id,inspection_id,violator_id,violation_date, code/type, fine amounts, and an unstructureddescription.
Normalization procedures include categorical encoding (label/one-hot), standardized text cleaning (lowercasing, punctuation/stop-word removal, tokenization with ~50,000 vocabulary), date conversion (Unix timestamp/cyclical encoding), and train/test stratification (70%/30% by severity). The schema design facilitates direct integration with established ML frameworks.
3. Statistical Profile and Visualization
CSDataset exhibits the following record volumes and qualitative properties:
| Type | Record Count | Example Features | Narrative Length |
|---|---|---|---|
| Incidents | 52,348 | event_type, degree_of_inj_x, abstract | 150 words (SD ≈ 40) |
| Inspections | 76,120 | complaint_type, inspection_result, notes | 100 words (avg.) |
| Violations | 61,445 | violation_type, penalty_amount, description | 80 words (avg.) |
Severity levels in incidents are distributed as: 0 (minor) 58%, 1 (22%), 2 (10%), 3 (7%), 4 (fatal) 3%. Year-over-year incident frequencies are exemplified in the following LaTeX table:
Severity histogram: $\begin{array}{c|ccccc} \text{Severity} & 0 & 1 & 2 & 3 & 4\hline \%\text{Incidents} & 58 & 22 & 10 & 7 & 3 \end{array}$
The structured diversity and abundance of narrative content make CSDataset particularly suitable for deep representation learning and explanatory modeling.
4. Cross-Level Linkages and Analytical Paradigms
A core feature of CSDataset is the explicit mapping of incidents to preceding/following inspections and their associated violations. The activity_nr provides robust site event alignment; joint analysis supports causal and policy studies. For instance, the effect of complaint-driven inspections on subsequent incident rates is operationalized as:
Propensity score analysis indicates an absolute reduction of 17.3% in the likelihood of incidents following complaint-driven inspections compared to non-complaint groups within matched control samples. This enables statistically sound evaluation of policy interventions and post hoc explanation of regulatory efficacy.
5. Benchmark Tasks and Baseline Algorithms
CSDataset supports several key ML and LLM tasks:
- Incident Severity Classification (5-way): Predict
degree_of_inj_xusing structured and textual features. - Violation Prediction: Estimate violation probability given inspection metadata.
- Root-Cause Extraction: Use LLMs for narrative-driven causal analysis.
Baseline implementations leverage both traditional ML classifiers (Logistic Regression, SVM, Random Forest, XGBoost, MLP with TF-IDF and structured inputs) and LLMs (GPT-4.1-mini, Qwen2.5-7B). On the severity prediction task, GPT-4.1-mini achieves the highest metrics (acc: 0.835, F1: 0.820). Hyperparameters and protocol details are explicitly documented, facilitating reproducible benchmarking.
6. Access, Loading, and Reproducibility
CSDataset is fully accessible via GitHub:
1 2 3 |
git clone https://github.com/zhenhuiou/Construction-Safety-Dataset-CSDataset.git cd Construction-Safety-Dataset-CSDataset pip install -r requirements.txt |
Standard loading procedures use pandas, and feature engineering aligns with mainstream ML frameworks. Data merging across levels is trivial via the provided relational keys. Example code integrates tabular and text features and demonstrates model training routines, removing barriers to direct experimental replication.
7. Research Implications and Expansion Trajectories
CSDataset supports advanced research directions across risk modeling, policy analysis, causal inference, and multimodal learning. Applications include predictive analytics at the project or worker level, evaluation of complaint-driven regulatory interventions, hazard identification with LLMs, and regional/seasonal incident forecasting.
Potential extensions include integrating near-miss reports, fusing site sensor (IoT) data, incorporating image/video for cross-modal learning, encoding multi-level relational structure in graph neural networks, and fine-tuning LLMs on domain-specific narratives for causal-explanatory reasoning.
The multi-level, richly annotated structure spanning incidents, inspections, and violations, with both structured fields and detailed free-text, situates CSDataset as a benchmark for ML, LLMs, and causal modeling in construction safety science (Ou et al., 9 Aug 2025).