TRACE: Temporal Reconstruction with Aligned Context Explanations for anomaly detection in building energy systems
Abstract
Anomaly detection in building management systems (BMS) presents two challenges: context-agnostic thresholding, in which a single global threshold cannot simultaneously accommodate high-load weekday peaks and low-load weekend periods, and unfaithful temporal attribution, in which explanation maps are decoupled from the underlying detection signals. This paper proposes TRACE (Temporal Reconstruction with Aligned Context Explanations), a unified framework that addresses both challenges within a single training objective. TRACE conditions the reconstruction encoder on cyclic temporal embeddings and calibrates anomaly thresholds independently per operational group, suppressing systematic false alarms without requiring separate context-specific models. Two complementary regularization terms shape temporal attention: an alignment loss that couples attention weights to the per-timestep reconstruction error, and a sparsity loss that concentrates attribution on the most informative timesteps. At inference, TRACE produces a detection decision alongside a two-dimensional attribution map identifying anomalous timesteps and responsible sensor channels. Experiments on two public benchmarks demonstrate the effectiveness of the proposed approach. On the Building Data Genome Project 2 (BDG2), TRACE achieves an F1-score of 0.767 and AUC-ROC of 0.845, reduces Context-FPR by 50% relative to LSTM-AE, and surpasses GradientSHAP in both Faithfulness@6 (0.401 vs. 0.340) and Stability (0.592 vs. 0.493). On the Secure Water Treatment (SWaT) dataset, where occupancy-driven daily patterns are absent, performance gains proportionally decrease, confirming that the benefit of context conditioning scales with the strength of the periodic occupancy structure in the data.