← All writing
Applied AI May 2025 12 min read

Benchmarking Incident Classification: Logistic Regression, XGBoost, and BERT on 100,000 OSHA Records

BERT wins on the injury and how it happened. XGBoost wins on the equipment that caused it. Across a decade of OSHA Severe Injury Reports, the right model depends on which OIICS axis you classify, and a weighted score hides the rare hazards.

Benchmarking Incident Classification: Logistic Regression, XGBoost, and BERT on 100,000 OSHA Records
Illustration: AI-generated · How this site is made
Interactive Tool & Open-Source Code: This benchmark powers the live OSHA Incident Classification Tool, trained on federal severe injury data from 2015 to 2025. The complete training pipeline, serialized artifacts, and application code are open source on GitHub. You can test your own narratives and inspect raw model outputs directly in the application.

When an employee suffers an amputation, in-patient hospitalization, or loss of an eye, federal regulation (29 CFR 1904.39) requires employers to notify OSHA within 24 hours. The resulting narrative is usually three sentences typed in haste by a plant manager:

"Employee was operating circular saw on table. Saw blade kicked back and struck left thumb, resulting in partial amputation."

To analyze systemic risk across multiple facilities, that free text cannot remain free text. It must be mapped into the Occupational Injury and Illness Classification System (OIICS) Version 2.01, the US counterpart to the European ESAW classification. OIICS demands four discrete classifications for every single event:

  1. Nature of Injury: The physical characteristic of harm (e.g., Amputations, Fractures).
  2. Part of Body: The specific anatomical location (e.g., Finger(s), fingernail(s)).
  3. Source of Injury: The physical object, equipment, or chemical that inflicted the injury (e.g., Cutting handtools—powered).
  4. Event Type: The physical mechanism of contact (e.g., Struck by object, Caught in running equipment).

In commercial EHS software, this is handled by forcing the user through four cascading dropdown menus containing hundreds of standardized codes. Frontline supervisors under shift pressure do not browse 400 codes. They pick the first code that sounds plausible, or they pick "Other." The data model breaks at the point of capture.

You might ask why not simply send these incident narratives to a commercial cloud large language model via API. In an enterprise EHS environment, three operational realities rule out third-party cloud LLMs as the default capture layer:

  1. Data sovereignty and privacy: Incident narratives contain confidential employee health information, worker names, and specific injury descriptions subject to strict medical privacy boundaries and worker council agreements.
  2. Inference latency and reliability: A plant operating in a low-connectivity industrial area cannot depend on a 2,000-millisecond external API round-trip when an operator submits a report; an on-premise classifier runs locally in under 15 milliseconds.
  3. Deterministic taxonomy alignment: General-purpose generative models hallucinate non-existent categories or drift across versions. Legal recordkeeping requires deterministic classification against standard schemas. The same split between narrative parsing and fixed legal rules drives AI OSHA recordkeeping through MCP.

Your job as an EHS leader is not to train machine learning models or tune mathematical loss functions. Your job is to understand where these models fail so you can specify the right data architecture and hold software vendors accountable when they pitch automated classification.

To test whether statistical machine learning can eliminate this administrative bottleneck without sacrificing legal recordkeeping fidelity, we trained and evaluated three distinct model architectures on over 100,000 federal records from OSHA's Severe Injury Reports database (January 1, 2015 to February 28, 2025):

  • Logistic Regression: A baseline model scoring how frequently specific words and two-word phrases (like "circular saw") appear in an incident narrative.
  • XGBoost: A decision-tree model that evaluates a sequence of strict yes/no rules across vocabulary lists to make predictions.
  • BERT: A modern language model (transformer) that reads entire sentences in both directions to understand how grammatical context changes the meaning of words.

The novelty here is not the algorithms themselves—data science teams have benchmarked these architectures for years. The insight is how the physical nature of workplace hazards breaks standard machine learning assumptions: sentence-level language models excel at narrative injury syntax, while decision-tree models excel at concrete industrial equipment.

Incident Classification Benchmark: Three Models, Four OIICS Axes

OSHA's severe injury records present an extreme classification problem. Even after consolidating specific 4th-level sub-codes into the 3rd-level OIICS hierarchy (grouping hyper-specific variants into stable parent categories), the label space remains wide and highly uneven.

To evaluate performance across this uneven space, we use the weighted F1-score, which balances false alarms against missed classifications while accounting for record volume in each category:

Model ArchitectureNature of Injury (F1)Part of Body (F1)Event Type (F1)Source of Injury (F1)
🥇 BERT (Fine-Tuned)0.750.720.590.35
🥈 XGBoost0.670.700.540.50
🥉 Logistic Regression (Baseline)0.650.620.520.48

The performance split follows the underlying physics of the four OIICS axes:

1. Where Transformers Dominate: Syntax and Bodily Context

BERT achieved the highest performance on Nature of Injury (0.75 F1) and Event Type (0.59 F1).

Both categories depend entirely on sentence structure rather than standalone keywords. The words "cut" or "struck" can describe an action, a state, or an object depending on sentence order. BERT reads sentences in both directions at once to parse grammatical relationships across the narrative, allowing it to correctly identify the sequence of physical failure.

2. Where Decision Trees Win: Equipment and Physical Sources

On Source of Injury, BERT's performance collapsed to 0.35 F1, while XGBoost maintained 0.50 F1 (with Logistic Regression close behind at 0.48 F1).

Industrial sources are concrete, discrete nouns: forklift, scaffold, circular saw, press brake. Transformers often dilute concrete equipment terms by over-analyzing surrounding verbs and adjectives rather than isolating the physical object that inflicted harm. XGBoost evaluates a chain of strict yes/no decision rules on specific keywords, isolating equipment names without getting confused by narrative phrasing.

Case Studies: When Simpler Models Win

Aggregate metrics hide how models fail on site. Individual predictions illustrate the operational trade-offs between linear token matching, tree splits, and neural attention.

Case 1: The Sprained Wrist (Linear Models Win on Explicit Specificity)

Narrative: "A prep cook slipped and fell in the kitchen area of a coffee shop, resulting in a sprained wrist. The incident occurred when cook stepped on a wet floor near the dishwashing station, causing him to lose balance and fall, landing on his right wrist."

DimensionLogistic RegressionXGBoostBERT
Nature of Injury✅ Sprains, strains (21%)❌ Fractures (24%)❌ Nonspecified injuries (44%)
Part of Body✅ Wrist(s) (57%)✅ Wrist(s) (89%)✅ Wrist(s) (68%)
Event Type✅ Fall on same level (12%)✅ Fall on same level (71%)✅ Fall on same level (88%)
Source of Injury✅ Floors (4%)✅ Floors (71%)✅ Floors (70%)

Because OSHA Severe Injury Reports mandate reporting only for amputations, in-patient hospitalizations, and loss of an eye under 29 CFR 1904.39, the dataset has an inherent prior favoring severe traumatic outcomes. True sprains, strains, and minor first-aids are rare in this database. While this federal dataset provides the largest audited benchmark available for serious incidents, an operational plant model must be calibrated against site-level near-miss logs to handle high-frequency, low-severity ergonomics.

BERT and XGBoost assigned higher probability to the statistical majority class (Fractures), because the training distribution heavily favored broken bones over soft-tissue injuries in hospitalization cases. The simpler Logistic Regression model, which assigns a direct linear weight to the exact token "sprained", was the only architecture that correctly identified the injury nature.

Case 2: The Carpenter's Laceration (Decision Trees Catch Mechanical Nuance)

Narrative: "A carpenter sustained a minor laceration on his left index finger while using a circular saw at construction site. The incident occurred when the saw blade caught on a piece of wood, causing a momentary loss of control and a superficial cut to carpenter's finger."

DimensionLogistic RegressionXGBoostBERT
Nature of Injury✅ Cuts, lacerations (49%)✅ Cuts, lacerations (79%)✅ Cuts, lacerations (92%)
Part of Body✅ Finger(s) (62%)✅ Finger(s) (94%)✅ Finger(s) (90%)
Event Type❌ Struck, caught (0.2%)✅ Injured by handheld object (25%)❌ Struck, caught (16%)
Source of Injury✅ Cutting handtools—powered (17%)✅ Cutting handtools—powered (51%)❌ Cutting handtools—nonpowered (15%)

All three models correctly identified the anatomical location and injury type. But look at the Source of Injury:

  • XGBoost correctly assigned the source to Cutting handtools—powered (51% confidence).
  • BERT misclassified the source as Cutting handtools—nonpowered (15% confidence).

BERT failed to connect the modifier "circular saw" to the broader functional category of powered tools, while XGBoost split directly on exact multi-word phrases like "circular saw" and "saw blade".

Beyond single-source classification, industrial events frequently involve compound mechanisms. An operator who slips from a ladder and catches an arm inside an unguarded machine suffers both a fall from height and machine entanglement. While our benchmark evaluates discrete 3rd-level OIICS categories to isolate architecture performance, a production pipeline must support multi-label classification to assign multiple valid categories without forcing a supervisor to pick one true physical event at the expense of another.

The Class Imbalance Problem: Why Weighted Accuracy Hides Rare Hazards

If you evaluate an EHS classification model using only overall accuracy or weighted F1, you build an operational blind spot directly into your incident register.

In Excel terms, the difference between these metrics is straightforward:

  • Weighted Average F1 (0.75): Scores overall accuracy while weighting each category by its record volume. High-frequency events (like ladder fractures) dominate the score.
  • Macro Average F1 (0.26): Calculates a simple unweighted average across every category. It treats a rare chemical burn with the exact same mathematical weight as 5,000 common fractures.

This divergence reveals the statistical reality of industrial safety data:

Class GroupRepresentative CategoriesTraining VolumeF1-Score RangeImpact on Evaluation
High-FrequencyFractures, Amputations, Cuts85,000+ records0.85 – 0.92Inflates Weighted F1
Low-FrequencyChemical Burns, Heat Burns, Poisoning< 500 records0.00 – 0.15Collapses Macro F1

A model with a 0.75 weighted F1 will reliably classify the 50th ladder fracture of the quarter. But when a rare, high-potential precursor event occurs—such as a chemical splash or acute vapor inhalation—the model's confidence drops to near zero, or it forces the narrative into a dominant traumatic injury bucket.

If your EHS software relies on raw automated classification without inspecting macro-level class coverage, it will systematically erase rare catastrophe signals from your executive dashboards.

Production Architecture: The Two-Tier Triage Engine

In an enterprise deployment, machine learning should never act as an unmonitored decision-maker that silently updates records. It must function as an operational triage valve.

Instead of accepting all model outputs, the system routes records based on an established cutoff score (an 80% confidence threshold):

Operational DimensionPath A: Direct Auto-Triage (Confidence ≥ 0.80)Path B: Specialist Review Queue (Confidence < 0.80)
Routing CriteriaHigh model certainty on standard kinetic mechanismsAmbiguous narrative, complex wording, or rare hazard class
System ActionAuto-populates OIICS code directly into databasePresents narrative with top-3 candidate codes pre-ranked
Verification StateMarked as machine-verified; immediate dashboard ingestFlags ambiguity; requires one-click specialist confirmation
Volume AllocationClears 60% to 70% of routine plant reportingReserves human review for the 30% to 40% that carry risk

Operational Impact

By setting an 80% confidence threshold:

  • 60% to 70% of routine records (simple ladder falls, standard fingertip lacerations) clear the threshold and auto-populate without human data entry.
  • 30% to 40% of ambiguous or rare records are routed to a safety specialist's review queue with the top-3 candidate classifications pre-selected.

This eliminates roughly two-thirds of the administrative data-entry workload across plant safety teams, while ensuring that ambiguous, complex, or rare high-hazard events receive expert review.

Asymmetric Risk-Weighted Thresholds

A static 80% confidence threshold assumes that all classification errors carry equal operational risk. In an industrial plant, they do not. Misclassifying an ankle sprain as a contusion is an administrative discrepancy; misclassifying a high-voltage arc flash or an enclosed vessel atmospheric exposure as a routine surface burn suppresses an immediate fatality precursor.

Production architectures must therefore implement asymmetric, risk-weighted gating:

  • Routine kinetic mechanisms (slips, trips, repetitive hand tool cuts): A 75% confidence threshold (0.75) allows high automation throughput.
  • Critical energy precursors (high-voltage electrical, toxic chemical exposure, mobile plant interaction, suspended loads): A 95% threshold (0.95), or mandatory human routing to an experienced EHS investigator regardless of raw model confidence.

Technical Implementation: Open-Source Architecture

The complete code, training routines, and serialized model checkpoints are open source on GitHub.

Open-Source Repository: The full codebase—including custom feature transformers, multi-head PyTorch architectures, XGBoost serialization dictionaries, and the live Streamlit interface—is published at github.com/srhtdmrkl/incident-classification-tool.

The repository provides:

  • Training & Evaluation Pipelines: Preprocessing, lemmatization, and multi-model training scripts across 100,000+ federal records mapped to the 3rd-level OIICS hierarchy.
  • Serialized Model Checkpoints: Production-ready model artifacts for Logistic Regression, XGBoost dictionaries, and fine-tuned BERT (.pkl and .pth).
  • Interactive Inference App: The complete Streamlit application code with real-time model comparison and probability distribution breakdowns.

The Strategic Takeaway

Machine learning in EHS is not an automated replacement for professional investigation. Its value lies in eliminating form friction for routine traumatic events, while using model uncertainty and risk weighting as a filter to direct safety specialists to the incidents that matter.

When evaluating automated classification capabilities in commercial software:

  1. Demand the F1 breakdown across both axes: If a vendor reports a single "92% accuracy" metric, they are hiding their failure on rare fatality precursors. Demand the Macro-F1 and the Source of Injury score.
  2. Insist on multi-architecture routing: Transformers belong on unstructured event descriptions and injury mechanisms; decision tree pipelines belong on physical tools, chemicals, and equipment sources.
  3. Configure asymmetric triage thresholds: Never allow a model to silently classify records below an 80% confidence threshold, and enforce mandatory human review on any narrative containing high-consequence energy sources.
  4. Demand local, deterministic inference: Verify whether the vendor runs lightweight on-premise classification or exports raw employee incident narratives across third-party generative APIs. If they cannot explain how they protect medical privacy and ensure deterministic OIICS code outputs, the system is an unvetted prototype.
Serhat Demirkol
Serhat Demirkol

A decade running management systems on-site, then seven years leading product for enterprise EHS software. Builds the tools, then writes about why most of them fail.

Keep reading