Make Your Home Safe: Time-aware Unsupervised User Behavior Anomaly Detection in Smart Homes via Loss-guided Mask

Jingyu Xiao, Zhiyao Xu, Qingsong Zou, Qing Li, Dan Zhao, Dong Fang, Ruoyu Li, Wenxin Tang, Kang Li, Xudong Zuo, Penghui Hu, Yong Jiang, Zixuan Weng, Michael R. LyuKDD 2024 · DOI

Abstract

Smart homes, powered by the Internet of Things, offer great convenience but also pose security concerns due to abnormal behaviors, such as improper operations of users and potential attacks from malicious attackers. Several behavior modeling methods have been proposed to identify abnormal behaviors and mitigate potential risks. However, their performance often falls short because they do not effectively learn less frequent behaviors, consider temporal context, or account for the impact of noise in human behaviors. In this paper, we propose SmartGuard, an autoencoder-based unsupervised user behavior anomaly detection framework. First, we design a Loss-guided Dynamic Mask Strategy (LDMS) to encourage the model to learn less frequent behaviors. Second, we propose a Three-level Time-aware Position Embedding (TTPE) to incorporate temporal information into positional embedding to detect temporal context anomaly. Third, we propose a Noise-aware Weighted Reconstruction Loss (NWRL) that assigns different weights for routine behaviors and noise behaviors to mitigate the interference of noise behaviors during inference. Comprehensive experiments on three datasets with ten types of anomaly behaviors demonstrates that SmartGuard consistently outperforms state-of-the-art baselines and also offers highly interpretable results.

Introduction

As smart homes become ubiquitous, they introduce unique security risks ranging from simple user errors (e.g., leaving a stove on) to malicious attacks (e.g., a hacker disabling security cameras). Detecting these "abnormal behaviors" is challenging due to three primary factors:

  1. Behavior Imbalance: Daily routines are repetitive, while critical behaviors happen rarely, making them hard for standard models to learn.
  2. Temporal Context: An action's validity often depends on its timing (e.g., AC on in winter) or duration (e.g., a water valve left open for hours).
  3. Noise: Smart home logs contain "passive" device actions or sporadic user behaviors that can trigger false alarms.
Examples of four types of context anomalies in smart homes: single device, multiple devices, moment-based, and duration-based.

To address these, the researchers categorized anomalies into four types: single device context anomalies, multiple device context anomalies, device control-moment anomalies, and device control-duration anomalies, as illustrated above.

Methods

SmartGuard is an unsupervised framework built on a Transformer-based autoencoder. It introduces three novel components to solve the challenges of imbalance, time, and noise:

The SmartGuard framework architecture, highlighting the Loss-guided Dynamic Mask Strategy (LDMS), Three-level Time-aware Position Embedding (TTPE), and Noise-aware Weighted Reconstruction Loss (NWRL).
  • Loss-guided Dynamic Mask Strategy (LDMS): Instead of random masking, LDMS tracks behaviors with high reconstruction loss—typically the rare or complex patterns—and prioritizes masking them. This forces the model to focus on learning infrequent but critical behaviors.
  • Three-level Time-aware Position Embedding (TTPE): This component embeds order-level (sequence), moment-level (hour/day), and duration-level (state length) information, allowing the model to detect anomalies tied to specific times or durations.
  • Noise-aware Weighted Reconstruction Loss (NWRL): During inference, the model identifies "noise" behaviors based on historical variance and assigns them lower weights, preventing sporadic, harmless actions from being flagged as high-risk anomalies.

Results and Key Insights

The researchers evaluated SmartGuard on three real-world datasets: a custom dataset (AN) simulating a family's device usage, and two public datasets (FR and SP).

  • Superior Performance: SmartGuard consistently outperformed eight major baselines, including deep learning approaches like TransAE and ARGUS. On the AN dataset, it achieved F1-scores of 0.98 to 0.99 across all anomaly types.
  • Temporal Accuracy: The model showed the most significant improvement in detecting "Duration" and "Moment" anomalies, where previous models often struggled (reaching ~0.99 F1-score vs. 0.60–0.70 for baselines).
  • Efficiency and Interpretability: The model is lightweight, with a detection time of approximately 0.0145 seconds. Furthermore, its attention mechanism allows for interpretable results, helping users understand which device action triggered an alarm.

Conclusion

SmartGuard provides a robust solution for smart home security by effectively modeling rare behaviors and complex temporal contexts. While the model requires an initial "warm-up" period to establish routines, its high accuracy and real-time efficiency make it a practical tool for modern IoT environments. Future research will explore adapting the framework to "concept drift," ensuring the system evolves alongside naturally changing user habits without increasing false positives.

Summary updated

BibTeX
@inproceedings{xiao2024make,
  author = {Jingyu Xiao and Zhiyao Xu and Qingsong Zou and Qing Li and Dan Zhao and Dong Fang and Ruoyu Li and Wenxin Tang and Kang Li and Xudong Zuo and Penghui Hu and Yong Jiang and Zixuan Weng and Michael R. Lyu},
  title = {{Make Your Home Safe: Time-aware Unsupervised User Behavior Anomaly Detection in Smart Homes via Loss-guided Mask}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2024},
  doi = {10.1145/3637528.3671708},
}
Figure