3. Exploratory analysis of multi-output injury data

Before any multi-output model is trained, the injury dataset must be interrogated as a system of correlated targets, not as a set of independent labels. In occupant injury prediction, the outputs typically include AIS severity per body region (head, neck, chest, abdomen, spine, upper and lower extremities), sometimes paired with continuous response variables such as HIC15, chest deflection, or femur force. Exploratory analysis at this stage answers three questions that directly shape architecture, loss weighting, and evaluation: how strongly do body-region targets co-vary, how skewed is each severity class, and how should missing targets be represented so the model neither learns from nor is penalized for absent ground truth.

Correlation structure among body regions

Injury outcomes are physically coupled through the restraint system and load path. A belt-loaded chest and a head excursion toward the B-pillar are not independent events; frontal impact data frequently show moderate positive association between chest and head AIS, while abdomen and lower-extremity injuries can be nearly uncorrelated or even weakly negative under certain loading geometries. The first analytical step is to compute pairwise association on the observed subset for each target pair, using Spearman's ρ for ordinal AIS and Cramér's V for categorical severity bins. Report the pairwise count n_ij alongside each coefficient, because pairwise deletion silently changes the sample and can inflate apparent correlation when missingness is structured.

A practical diagnostic is to compare the observed correlation matrix against the correlation implied by a model that predicts each target independently. Large positive residual correlation indicates shared latent structure that a multi-output head with a shared trunk can exploit; near-zero residual correlation suggests region-specific heads with limited sharing. The following snippet computes the pairwise Spearman matrix with explicit observation counts and flags pairs whose support falls below a threshold:

import pandas as pd
from scipy.stats import spearmanr

targets = ["ais_head", "ais_neck", "ais_chest",
           "ais_abdomen", "ais_spine", "ais_upper_ext", "ais_lower_ext"]

rows = []
for i, a in enumerate(targets):
    for b in targets[i+1:]:
        mask = df[a].notna() & df[b].notna()
        n = int(mask.sum())
        rho = spearmanr(df.loc[mask, a], df.loc[mask, b]).statistic if n > 30 else float("nan")
        rows.append({"pair": f"{a}~{b}", "n_obs": n, "rho": round(rho, 3),
                     "low_support": n < 200})

corr_table = pd.DataFrame(rows).sort_values("rho", ascending=False)
print(corr_table.head(10))

Read the output in two passes. First, inspect pairs with high ρ and adequate support — these are candidates for shared representation or auxiliary loss terms. Second, inspect pairs with low n_obs; a high ρ computed on 40 cases is not evidence of coupling, and treating it as such will bias the loss toward rare co-occurrence patterns. In typical frontal-impact extracts, chest–head and chest–spine pairs often show ρ in the 0.25–0.45 range, while abdomen–lower extremity pairs frequently fall below 0.15; these are illustrative ranges, not fixed expectations, and must be recomputed per dataset.

Class imbalance across severity levels

AIS-coded targets are severely imbalanced: MAIS 0–1 dominates, MAIS 3+ is uncommon, and MAIS 5–6 may appear only a few dozen times across thousands of records. The imbalance is not uniform across regions — head and chest tend to carry more high-severity cases than abdomen or spine — so a single global class weight is usually the wrong remedy. Quantify per-target, per-class frequency and the co-occurrence of severe outcomes before choosing a strategy.

TargetClass 0–1 (%)Class 2 (%)Class 3+ (%)Min class count
ais_head71.417.211.4412
ais_chest64.821.513.7496
ais_abdomen88.98.13.0108
ais_spine91.26.42.487
ais_lower_ext83.511.05.5199

The table above is a representative example distribution, not measured results. Its purpose is to show the decision logic: abdomen and spine have minimum class counts under 100, which means stratified splitting must guarantee those cases appear in validation, and any per-class metric on them will have wide confidence intervals. For these targets, consider ordinal formulation (predicting AIS as an ordered level with cumulative-link loss) rather than flat multiclass softmax, because ordinal loss shares statistical strength across adjacent severity levels and is less sensitive to the rarest bin. For head and chest, where class 3+ counts exceed 400, standard class-weighted cross-entropy with weights inversely proportional to frequency is usually adequate.

Compute class weights from the training split only, then reuse them unchanged for validation and test. Recomputing weights per split leaks distributional information and makes validation loss incomparable across runs.

Missing target handling

Missing injury labels are the norm, not the exception. A crash record may lack abdomen AIS because the autopsy or medical report did not code it, because the occupant was uninjured in that region and the field was left blank, or because the case was extracted from a source with different coding depth. These mechanisms are not equivalent, and the handling strategy must distinguish them.

Three patterns deserve explicit treatment. Structurally absent targets occur when a region was never assessed; these should be masked out of the loss entirely. Implicitly zero targets occur when absence of coding means no injury; these should be imputed as class 0, but only after verifying the coding convention in the data dictionary. Randomly missing targets occur when coding was skipped for administrative reasons; these are the only case where imputation or a missingness indicator is defensible. A quick diagnostic is to cross-tabulate missingness against injury severity of other regions: if abdomen missingness rises sharply among high-MAIS cases, the mechanism is likely informative and a binary missingness indicator should be added as an auxiliary input rather than imputing a value.

# Masked multi-output loss: ignore targets with no ground truth
import torch, torch.nn.functional as F

def masked_ce(logits, targets, mask, class_weights):
    # logits: [B, R, C]  targets: [B, R]  mask: [B, R] bool
    B, R, C = logits.shape
    loss = F.cross_entropy(
        logits.reshape(B * R, C),
        targets.reshape(B * R),
        weight=class_weights,
        reduction="none",
    ).reshape(B, R)
    return (loss * mask).sum() / mask.sum().clamp(min=1.0)

The masked loss above is the minimal correct implementation: it excludes unobserved targets from both numerator and denominator, so a batch with many missing abdomen labels does not dilute the gradient for head and chest. Two failure modes are common. First, if mask.sum() is not clamped, batches where every target is missing produce a division by zero and NaN gradients. Second, if class weights are applied inside the masked reduction without renormalization, the effective learning rate for rare targets drifts with the missingness pattern; monitor per-target loss separately during the first few hundred steps to confirm stability.

Injury Dataset 7 region targets AIS 0–6 + continuous Correlation Structure Spearman ρ per pair n_obs alongside each ρ flag low-support pairs → shared vs. region heads Class Imbalance per-target class frequency min class count check ordinal vs. flat softmax → loss weighting choice Missing Targets structural / implicit / random missingness vs. severity masked loss + indicator → mask design Design Decisions trunk sharing loss formulation class weights masking strategy Model Spec architecture loss + weights split protocol re-audit after first training run: residual correlation, per-target loss drift

From diagnostics to a defensible split protocol

The three analyses converge on a split protocol that must be fixed before training. Stratify on the coarsest severity bin of the two most imbalanced targets (abdomen and spine in the example above) so that rare cases appear in every fold; verify that the minimum class count in validation is at least 20 for each target, and if not, merge adjacent severity bins for that target only. Record the observed correlation matrix and class frequencies as a versioned artifact alongside the split indices, because any later change to the target set or coding convention invalidates both. When the first training run completes, return to the same diagnostics: residual correlation between predicted targets that exceeds the observed correlation suggests the shared trunk is over-coupling regions, while per-target loss that drifts upward for a high-missingness target indicates the mask or class weights need revision. This closed loop — diagnose, decide, train, re-audit — is what separates a multi-output injury model that generalizes from one that merely fits the majority class.