Next Article in Journal
AI-MDD-UX: Revolutionizing E-Commerce User Experience with Generative AI and Model-Driven Development
Previous Article in Journal
Detecting Disinformation in Croatian Social Media Comments
Previous Article in Special Issue
Optimizing IoT Video Data: Dimensionality Reduction for Efficient Deep Learning on Edge Computing
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Edge AI for Real-Time Anomaly Detection in Smart Homes

by
Manuel J. C. S. Reis
1,2,* and
Carlos Serôdio
1,3
1
Engineering Department, University of Trás-os-Montes e Alto Douro, 5000-801 Vila Real, Portugal
2
IEETA—Institute of Electronics and Informatics Engineering of Aveiro, 3810-193 Aveiro, Portugal
3
Algoritmi Center, 4800-058 Guimarães, Portugal
*
Author to whom correspondence should be addressed.
Future Internet 2025, 17(4), 179; https://doi.org/10.3390/fi17040179
Submission received: 22 March 2025 / Revised: 14 April 2025 / Accepted: 16 April 2025 / Published: 18 April 2025

Abstract

:
The increasing adoption of smart home technologies has intensified the demand for real-time anomaly detection to improve security, energy efficiency, and device reliability. Traditional cloud-based approaches introduce latency, privacy concerns, and network dependency, making Edge AI a compelling alternative for low-latency, on-device processing. This paper presents an Edge AI-based anomaly detection framework that combines Isolation Forest (IF) and Long Short-Term Memory Autoencoder (LSTM-AE) models to identify anomalies in IoT sensor data. The system is evaluated on both synthetic and real-world smart home datasets, including temperature, motion, and energy consumption signals. Experimental results show that LSTM-AE achieves higher detection accuracy (up to 93.6%) and recall but requires more computational resources. In contrast, IF offers faster inference and lower power consumption, making it suitable for constrained environments. A hybrid architecture integrating both models is proposed to balance accuracy and efficiency, achieving sub-50 ms inference latency on embedded platforms such as Raspberry Pi and NVIDEA Jetson Nano. Optimization strategies such as quantization reduced LSTM-AE inference time by 76% and power consumption by 35%. Adaptive learning mechanisms, including federated learning, are also explored to minimize cloud dependency and enhance data privacy. These findings demonstrate the feasibility of deploying real-time, privacy-preserving, and energy-efficient anomaly detection directly on edge devices. The proposed framework can be extended to other domains such as smart buildings and industrial IoT. Future work will investigate self-supervised learning, transformer-based detection, and deployment in real-world operational settings.

Graphical Abstract

1. Introduction

1.1. Background and Motivation

The proliferation of Internet of Things (IoT) devices has transformed traditional homes into interconnected smart environments, enhancing convenience, security, and energy efficiency. These devices continuously generate vast amounts of data, necessitating efficient processing and analysis methods to maintain optimal system performance. Traditionally, data from smart home devices are transmitted to centralized cloud servers for processing. While effective, this approach introduces challenges such as increased latency, potential privacy breaches, and dependence on stable internet connectivity. To mitigate these issues, there is a growing shift towards Edge Artificial Intelligence (Edge AI), where data processing occurs locally on the devices or nearby edge servers, enabling real-time analytics and decision-making [1,2].
In smart home ecosystems, real-time anomaly detection is crucial for identifying irregular patterns that may indicate security breaches, device malfunctions, or unsafe conditions. Implementing anomaly detection at the edge enhances responsiveness and preserves user privacy by minimizing data transmission to external servers. Recent advancements in Edge AI have demonstrated its potential in various applications, including predictive maintenance, energy management, and security monitoring within smart homes [3,4].

1.2. Research Problem and Objectives

Despite the advantages of Edge AI, developing efficient anomaly detection models suitable for resource-constrained edge devices remains challenging. Many existing models are computationally intensive and require substantial memory, making them impractical for deployment on typical smart home devices. Furthermore, the dynamic and heterogeneous nature of smart home environments complicates modelling normal behavior patterns, increasing the risk of false positives or negatives in anomaly detection.
This research addresses these challenges by developing a lightweight, real-time anomaly detection framework optimized for edge deployment in smart homes. The specific objectives are as follows:
  • Design an efficient anomaly detection architecture that leverages Edge AI to process data locally, reducing latency and preserving privacy.
  • Develop and implement lightweight machine learning models suitable for deployment on resource-constrained devices commonly found in smart homes.
  • Evaluate the proposed framework using simulated IoT data representative of typical smart home environments to assess its effectiveness in detecting anomalies.

1.3. Contributions

This study contributes to the field of smart home automation and Edge AI by the following:
  • Proposing a novel edge-based architecture for real-time anomaly detection tailored to the constraints and requirements of smart home environments.
  • Developing lightweight machine learning models that balance detection accuracy with computational efficiency, facilitating deployment on typical smart home devices.
  • Conducting comprehensive evaluations using simulated IoT data to validate the proposed framework’s performance and provide insights into its practical applicability.
This research addresses the challenges associated with on-device anomaly monitoring in smart homes. It aims to enhance the security, efficiency, and reliability of smart home systems, contributing to the broader adoption and trust in IoT technologies.
Our framework distinguishes itself from prior work by integrating a hybrid detection architecture with quantized inference and dynamic thresholding strategies, all tested on realistic embedded hardware platforms.
The remainder of this paper is structured as follows: Section 2 reviews related work in IoT anomaly detection, edge computing, and federated learning, highlighting existing gaps. Section 3 introduces the proposed Edge AI-based anomaly detection framework, detailing its architecture, data processing pipeline, and anomaly detection models. Section 4 describes the experimental setup, including dataset generation, model training, and evaluation metrics. Section 5 presents the results and discussion, comparing the performance of Isolation Forest and LSTM Autoencoder regarding accuracy, computational efficiency, and energy consumption. Section 6 concludes the paper by summarizing key findings and outlining future research directions, such as adaptive learning, transformer-based models, and real-world deployment considerations.

2. Related Work

2.1. IoT Anomaly Detection

Anomaly detection in IoT environments is crucial for identifying irregular patterns that may indicate security breaches, system malfunctions, or unsafe conditions. Recent studies have explored various machine learning approaches to enhance anomaly detection in smart homes. For instance, a 2023 study proposed a machine learning-based anomaly detection approach using classifiers such as Random Forest, decision tree, and AdaBoost, tested on the UNSW BoT IoT dataset [5]. Another 2023 research study focused on improving unsupervised anomaly detection within smart home environments through advanced learning methods [6].
Despite advancements, traditional cloud-based anomaly detection solutions face latency, privacy, and bandwidth challenges. Transmitting data to centralized servers can introduce delays, pose privacy risks, and strain network resources. These limitations underscore the need for decentralized approaches that process data locally, reducing dependence on cloud infrastructures.
Recent developments in deep learning-based anomaly detection have introduced models such as Variational Autoencoders (VAEs), transformer-based architectures, and hybrid CNN-LSTM approaches that outperform traditional machine learning techniques in time-series analysis [7]. These models leverage sequential dependencies in IoT sensor data to improve anomaly detection accuracy, making them well suited for smart home applications.
However, most existing works focus either on centralized deep learning or single-model edge approaches, lacking integrated solutions that combine statistical and deep learning techniques with full edge compatibility. Our work fills this gap by proposing a hybrid LSTM-AE and Isolation Forest framework designed for embedded inference. This fusion allows us to benefit from the strengths of both models while mitigating their individual weaknesses.
Unlike prior works, we focus on implementing quantized, power-efficient versions of these models to support real-time inference in constrained smart home environments.

2.2. Edge Computing and Edge AI

Edge computing brings data processing closer to the data source by utilizing local devices or edge servers, thereby mitigating the drawbacks of cloud-based systems. In the context of IoT, Edge AI refers to deploying artificial intelligence algorithms directly on edge devices, enabling real-time data analysis and decision-making.
Recent advancements in Edge AI have demonstrated its potential to enhance IoT applications. A 2024 study highlighted the integration of AI in IoT devices, emphasizing its role in transforming workloads and improving experiences across smart homes [8]. Another 2024 research discussed the challenges and technological advances in privacy-preserving workflows within distributed edge environments, which is crucial for smart home applications [9].
Federated learning (FL) has emerged as a viable privacy-preserving alternative to cloud-based AI, allowing smart home devices to collaboratively train models without transmitting raw sensor data to a central server [10,11]. This approach mitigates privacy risks and reduces the communication overhead associated with cloud-based retraining. Studies have demonstrated the feasibility of federated learning for IoT cybersecurity, anomaly detection, and privacy-sensitive applications [12]. Additionally, advancements in model quantization and optimization techniques, such as pruning and knowledge distillation, have further enhanced the efficiency of Edge AI for real-time IoT applications [13].
The integration of Edge AI in IoT systems offers several benefits:
  • Reduced latency: Local data processing enables immediate detection of anomalies, which is crucial for timely responses in smart home applications.
  • Enhanced privacy: Processing data on-device minimizes the exposure of sensitive information, addressing privacy concerns associated with cloud computing.
  • Lower bandwidth usage: By analyzing data locally, the need for constant data transmission to the cloud is reduced, conserving network bandwidth.
These advantages make Edge AI a compelling approach for implementing anomaly detection in smart home environments.

2.3. Research Gap

While traditional cloud-based anomaly detection methods have been extensively studied, they often fall short of meeting smart home applications’ real-time processing and privacy requirements. The reliance on centralized data processing introduces latency and potential security vulnerabilities, which are unacceptable in scenarios where immediate action is necessary.
Although Edge AI presents a promising alternative, its application in anomaly detection within smart homes remains underexplored. Challenges such as developing lightweight models operating efficiently on resource-limited devices, ensuring model accuracy, and maintaining energy efficiency must be addressed.
Recent studies have explored distributed AI architectures for anomaly detection, demonstrating that it is possible to create a scalable, federated anomaly detection system without significant loss of accuracy [7]. However, more research is needed to optimize inference efficiency, particularly for transformer-based models that require substantial computational resources. Future work will focus on refining hybrid models that combine Isolation Forest and LSTM Autoencoders with lightweight transformer architectures, striking a balance between computational efficiency and high anomaly detection accuracy.
This research aims to fill these gaps by proposing a lightweight anomaly detection framework optimized for edge devices in smart home settings. By leveraging recent advancements in Edge AI and machine learning techniques, the framework seeks to provide real-time, privacy-preserving anomaly detection without the drawbacks of cloud-based solutions.
While studies such as [14,15,16] have explored anomaly detection using autoencoders or transformer-based methods, these solutions are often computationally intensive and poorly suited for low-power edge deployment. In contrast, our proposed system is optimized for resource efficiency, offering a fully quantized implementation tested on real embedded platforms.
To the best of our knowledge, this is one of the first works to combine real-time reconstruction-aware thresholding, hybrid model fusion, and deployment-ready quantized Edge AI for anomaly detection in smart homes.

3. Proposed System Architecture

This work proposes an Edge AI-based anomaly detection framework tailored for smart home environments. The system ensures real-time data processing, enhances privacy, and optimizes energy efficiency while maintaining high anomaly detection accuracy. This architecture follows a multi-layered approach, incorporating IoT sensors, edge computing for AI-driven anomaly detection, optional cloud integration, and a user alerting system.
Our proposed system architecture draws inspiration from several key studies:
  • IoT Network Anomaly Detection in Smart Homes Using Machine Learning: This study presents a machine learning-based approach for detecting anomalies in smart home IoT networks, utilizing Random Forest and decision tree classifiers. The methodology and results informed our selection of efficient models suitable for edge deployment [5].
  • Enhancing Smart Home Security: Anomaly Detection and Face Recognition: This research study explores the integration of deep learning models for anomaly detection and face recognition within IoT devices, highlighting the importance of real-time, on-device processing to enhance security and privacy in smart homes [17].
  • Edge AI for Smart Home Applications: This article discusses the application of Edge AI in smart homes, emphasizing its role in enabling functionalities like motion detection and anomaly detection without relying on cloud services, thereby ensuring data privacy and reducing latency [3].

3.1. Overview of the Edge AI-Based Framework

At the core of this architecture lies a four-layered system, each playing a distinct role in ensuring seamless anomaly detection and response (Figure 1).
The first layer, IoT Sensor Layer, is responsible for data collection. Various smart home sensors continuously monitor environmental conditions and activities. These include temperature sensors (DHT22 and DS18B20), motion detectors (like PIR sensors and mmWave radar), and energy meters tracking power consumption. The raw data collected from these sensors form the foundation for subsequent anomaly detection.
Once collected, the sensor data flow into the Edge Processing Layer, where real-time analysis occurs. Instead of sending data to the cloud for processing, this layer runs machine learning-based anomaly detection algorithms directly on the edge device. A key advantage of this approach is the significant reduction in latency, allowing anomalies to be identified instantaneously rather than waiting for cloud-based analysis. More importantly, keeping data local enhances privacy, as no sensitive information is transmitted over the internet.
While core anomaly detection happens at the edge, the cloud layer is optional. In cases where additional model training or updates are required, the cloud can provide a more computationally intensive environment for refining machine learning models. If an anomaly is detected with low confidence, metadata (rather than raw data) are transmitted to the cloud layer for further validation, reducing bandwidth usage while improving accuracy through cloud-based models. If cloud-based verification is required, the system ensures that only minimal and necessary data are sent to mitigate privacy risks and computational overhead.
Cloud-based retraining is particularly beneficial when the system detects ambiguous anomalies that edge models cannot accurately classify. By aggregating data patterns from multiple smart homes, the cloud-based models can learn more sophisticated anomaly detection patterns and periodically update edge devices with improved detection capabilities.
Table 1 summarizes the key functionalities and components of each system layer to provide a structured overview of the proposed Edge AI-based anomaly detection framework. This breakdown highlights how different layers interact to enable efficient, real-time anomaly detection in smart home environments.

3.2. Anomaly Detection Approach

The system integrates two complementary machine learning models to enable accurate and efficient anomaly detection at the edge, balancing computational efficiency and detection performance.
The first model, Isolation Forest (IF), is a lightweight, unsupervised machine learning algorithm designed for efficient anomaly detection in high-dimensional datasets. Unlike traditional classification models requiring labelled training data, IF identifies outliers by isolating data points that significantly deviate from normal patterns. Its low computational overhead makes it well suited for real-time processing on resource-constrained edge devices. IF is especially effective for detecting point-based anomalies in temperature, motion, and power consumption, making it ideal for fast, low-power deployments in smart home environments. IF offers superior scalability and computational efficiency compared to one-class SVM, making it an ideal choice for anomaly detection in large-scale, high-dimensional IoT environments [18].
To complement the IF model, the system incorporates a Long Short-Term Memory Autoencoder (LSTM-AE), which is particularly adept at analyzing sequential data. Since smart home sensor readings often follow predictable temporal patterns, LSTM-AE models can learn these behavioral trends and detect deviations that indicate potential anomalies. Unlike IF, which primarily identifies isolated outliers, LSTM-AE effectively recognizes long-term irregularities, such as gradual energy consumption spikes or repetitive but anomalous activity patterns [19].

3.2.1. Advantages of Edge AI over Cloud-Based Detection

Deploying anomaly detection models directly on edge devices offers several key advantages over traditional cloud-based approaches, particularly in terms of latency, privacy, and bandwidth usage:
  • Lower latency: On-device processing eliminates the delay associated with cloud-based computation, enabling on-device anomaly monitoring and immediate response [20]. Edge AI-based detection can reduce latency from several hundred ms (typical for cloud processing) to under 50ms, making it suitable for time-sensitive applications.
  • Enhanced privacy: Keeping data local reduces the risk of exposing sensitive user information by limiting transmission to external servers. This approach ensures compliance with data protection regulations and enhances user trust.
  • Reduced bandwidth usage: Processing sensor data at the edge minimizes network congestion and reliance on cloud infrastructure, reducing overall bandwidth requirements by up to 80% compared to continuous cloud-based processing.
To further highlight the advantages of Edge AI-based anomaly detection over cloud-based methods, Table 2 compares key factors such as latency, privacy, bandwidth usage, scalability, and power consumption.
Additionally, Table 3 compares the effectiveness of different Edge AI approaches for anomaly detection, evaluating Isolation Forest, LSTM Autoencoder, and a hybrid approach.
By processing data locally while optimizing for performance and accuracy, Edge AI offers a compelling alternative to traditional cloud-based anomaly detection, making it particularly well-suited for real-time smart home IoT applications.

3.2.2. Model Selection Rationale

The Isolation Forest model was chosen over one-class SVM due to its higher efficiency in handling high-dimensional IoT data and its ability to detect outliers without requiring a labelled dataset. Although effective in some cases, one-class SVM is computationally expensive because it relies on complex kernel functions, making it impractical for real-time execution on low-power edge devices [18].
Similarly, the LSTM Autoencoder was selected over Gated Recurrent Units (GRUs) due to its superior ability to retain long-term dependencies in sequential data. While GRUs offer computational efficiency, they may struggle to capture extended behavioral trends, which are essential for accurate anomaly detection in smart home IoT environments [19].
Although transformer-based models, such as the Temporal Fusion Transformer (TFT) and Time Series Transformer (TST), have demonstrated promising results in sequential anomaly detection, they were not implemented in this study due to their high computational demands. These architectures rely on extensive matrix multiplications and self-attention mechanisms, significantly increasing inference time and memory consumption, making them unsuitable for resource-limited edge devices [21].

3.2.3. Future Work: Exploring Lightweight Transformer Variants

Future research will focus on evaluating lightweight transformer architectures optimized for edge deployment to further improve sequential anomaly detection while ensuring computational efficiency. These models offer a balance between accuracy and resource constraints, making them suitable for on-device anomaly monitoring in smart home environments.
Potential candidates include the following:
  • MobileViT—A mobile-friendly vision transformer that reduces computational complexity while preserving accuracy [22].
  • TinyBERT—A distillation-based transformer designed for low-power AI applications.
By integrating quantized and optimized deep learning architectures, future iterations of this framework aim to achieve higher anomaly detection accuracy while maintaining real-time processing capabilities on embedded IoT hardware. Additionally, further evaluations will assess the trade-offs between computational overhead and on-device anomaly monitoring performance to ensure optimal deployment in resource-constrained environments.

3.2.4. Mathematical Formulation of Anomaly Scores

In the Isolation Forest (IF) model, anomaly scoring is based on the path length of data points across a set of randomly constructed binary trees. The anomaly score s(x) for a sample x is computed as
s x = 2 E h x c n
where E(h(x)) is the average path length across all isolation trees, c(n) is the average path length in a binary search tree, approximated as
c n = 2 H n 1 2 n 1 n
and H(i) is the harmonic number, w i t h   H i l n i + γ (Euler–Mascheroni constant).
In the LSTM Autoencoder (LSTM-AE), anomaly scores are based on the reconstruction error of the input time series. The model is trained to minimize the mean squared error:
L M S E = 1 T t = 1 T | x t x t ^ | 2
where xt is the original input at time step t, x t ^ is the reconstructed output at time step t, and T is the length of the input time window. An input window is flagged as anomalous when the reconstruction loss exceeds a dynamic threshold defined from the training error distribution.
In order to detect anomalies using the LSTM-AE, we define an anomaly score for each input sequence as its reconstruction loss. During training, we calculate the distribution of mean squared errors (MSE) over normal data and select a threshold θ corresponding to a high percentile (e.g., 95th). An input is flagged as anomalous when
L M S E x > θ
To classify an input sequence as anomalous, we define a dynamic threshold θ based on the reconstruction loss values obtained from the training set. Specifically, we set θ as the 95th percentile of the training reconstruction loss distribution:
θ = Percentile 95 L train
During inference, an input window is flagged as anomalous if its reconstruction loss L x exceeds θ. This unsupervised strategy allows the system to adapt the decision boundary to each environment’s normal behavior, without requiring labeled anomalies.

3.3. Edge Deployment Considerations

Several model compression techniques were implemented to optimize performance on edge devices. Quantization improved inference speeds by up to 4.8 times, reducing processing time from several seconds to under 1 s on a Raspberry Pi 4, depending on the model’s complexity and quantization techniques applied. Previous studies have demonstrated that full-integer quantization can achieve latencies as low as 2.19 s for deep learning models, while optimized inference frameworks can lead to 79% energy savings and significant execution time reductions [23,24]. These findings reinforce the importance of quantization in enhancing edge AI efficiency for on-device anomaly monitoring.
By reducing the model’s complexity without significant loss of accuracy, real-time anomaly detection remains feasible on low-power devices.
Beyond computational efficiency, energy consumption is a critical factor in IoT-based systems. Since many edge devices are battery-powered, our system incorporates energy-efficient execution strategies to minimize power usage. By leveraging event-triggered processing, the model remains idle until an anomaly is suspected, reducing unnecessary energy expenditure. Furthermore, dynamic power management techniques allow the edge device to adjust its processing power based on workload demands.
By integrating these optimization strategies, the proposed system ensures that on-device anomaly monitoring is accurate, scalable, energy-efficient, and deployable on diverse edge hardware platforms.
Latency tests showed that the quantized LSTM Autoencoder model achieved inference speeds under 32.1 ms on an NVIDIA Jetson Nano, making it suitable for real-time applications.

4. Experimental Setup

This section outlines the methodology for validating the proposed Edge AI-based anomaly detection framework. The evaluation includes data simulation, model implementation, and performance assessment based on accuracy, computational efficiency, and energy consumption.

4.1. Data Simulation

A synthetic IoT dataset was generated to ensure a controlled evaluation environment, simulating sensor readings from a smart home environment. The dataset consists of 100,000 sensor readings with three key parameters:
  • Temperature (°C): Simulated using a normal distribution around typical indoor temperature.
  • Motion detection (binary: 0/1): Randomized based on expected human activity patterns.
  • Energy usage (wattage): Simulated with baseline values and occasional spikes to mimic high-power consumption events.
To introduce anomalies, 3% of the samples were deliberately altered to represent unusual events such as sudden temperature spikes, unexpected motion patterns, and excessive energy consumption. These anomalies were injected at random intervals to simulate realistic smart home scenarios.
The dataset size of 100,000 records was chosen to ensure statistical significance while maintaining computational feasibility for edge-based processing. The 3% anomaly rate aligns with industry reports on rare but impactful deviations in smart home environments.
Power consumption was measured using the INA219 power monitor sensor, capturing energy usage variations before and after deploying anomaly detection models. The INA219 sensor was configured to sample power usage at a fixed rate of 1 Hz, which provided a practical balance between energy profiling granularity and minimal overhead on system resources. The baseline energy usage of the Raspberry Pi 4 running idle processes was 2.7 W, compared to 4.2 W when executing the LSTM Autoencoder. The baseline power consumption (2.7 W idle, 4.2 W during execution) aligns with previous studies on energy-efficient Edge AI implementations, where models optimized with quantization typically operate within a similar power range [25,26].
The data pre-processing steps included the following:
  • Feature scaling: Min-Max normalization was applied to standardize sensor readings.
  • Noise reduction: A rolling average filter was used to smooth transient fluctuations in sensor data before feeding it into the anomaly detection models.
In addition to synthetic data, we evaluated the proposed framework on a subset of the CASAS smart home dataset. This subset includes multivariate sensor streams such as motion and temperature from the ‘Kyoto’ and ‘HH102’ environments. The data were preprocessed to match the structure of the synthetic dataset and used to validate model generalizability.

4.2. Model Implementation

The proposed system employs two complementary machine learning models for anomaly detection:
  • Isolation Forest (unsupervised anomaly detection): Identifies outliers based on data point separation.
  • LSTM Autoencoder (deep learning for sequential anomaly detection): Detects long-term deviations in sensor data patterns.
The dataset was split into an 80/20 train–test ratio, ensuring that anomalies were proportionally distributed in both sets. Model training was conducted on a PC with an Intel i7 processor (16 GB RAM), while inference testing was performed on an Edge AI device (Raspberry Pi 4, 4 GB RAM) to evaluate the feasibility of on-device anomaly monitoring.
Table 4 presents the hyperparameters used for training the Isolation Forest and LSTM Autoencoder models, ensuring consistency in model configuration. Hyperparameter tuning was performed using a grid search approach, optimizing for low latency and high detection accuracy. For the LSTM Autoencoder, the number of layers and units was chosen to balance model complexity with inference efficiency on edge devices. This hyperparameter tuning approach resulted in a 13% improvement in anomaly detection accuracy and a 3% reduction in false positives, aligning with previous studies that demonstrated reductions in false positive rates from 53.6% to 27.8% through optimized parameter selection [27,28]. These improvements highlight the importance of tuning key parameters to optimize edge inference reliability, ensuring a balance between detection accuracy and computational efficiency in resource-constrained environments.
To implement real-time anomaly detection at the edge, we employed Isolation Forest (IF), an unsupervised machine learning algorithm widely used for detecting anomalies in high-dimensional data. Unlike traditional classification models, Isolation Forest does not require labelled training data. Instead, it isolates anomalies by iteratively partitioning the dataset, identifying instances that appear isolated from the majority.
This method is particularly well suited for IoT environments due to its low computational cost and ability to detect outliers in complex sensor data. The algorithm was applied to temperature, motion, and energy usage readings, with the contamination parameter set to 0.03, meaning that approximately 3% of the dataset was identified as anomalous.
The Python 3.10.0 implementation in code 1 details how to use Isolation Forest to detect anomalies in smart home sensor data.
The code snippet in code 1 begins by generating synthetic IoT sensor data, simulating real-world conditions in a smart home environment. It then normalizes the data to ensure consistency in feature scaling before applying the Isolation Forest model. The algorithm assigns an Anomaly Score to each data point, classifying observations as either normal (0) or anomalous (1).
These results were subsequently analyzed using time-series visualizations (the full code available in Appendix A.1.: Isolation Forest Implementation) to illustrate how anomalies correspond to unexpected fluctuations in sensor readings.
To effectively detect anomalies in time-series IoT sensor data, we implemented an LSTM Autoencoder model. Unlike traditional anomaly detection methods, the LSTM Autoencoder learns normal behavioral patterns over time and identifies deviations based on reconstruction errors. The code snippet available in Appendix A.2.: LSTM Autoencoder Implementation illustrates the implementation of the model, including data pre-processing, training, and anomaly score computation.
Although the proposed models were validated using synthetic smart home data, their real-world applicability must be assessed on actual smart home deployments. Future experiments will utilize publicly available datasets such as the following:
  • UNSW BoT-IoT Dataset (captures real-world IoT traffic anomalies)
  • CASAS Smart Home Dataset (records user activity and environmental sensor data)
Real-world testing will evaluate deployment feasibility on smart home hardware platforms such as the following:
  • Raspberry Pi 4 (Edge AI baseline device)
  • NVIDIA Jetson Nano (optimized for deep learning inference)
  • ESP32 microcontroller (low-power anomaly detection)
By comparing model performance on these devices, we aim to determine the optimal trade-off between inference time, power consumption, and detection accuracy.

4.3. Evaluation Metrics

The performance of the anomaly detection models was evaluated based on the following key metrics:
  • Accuracy, precision, recall, and F1-score: Used to assess detection performance.
  • Inference time: Measured the time taken for on-device anomaly monitoring on the Raspberry Pi 4 compared to a cloud-based model execution.
  • Memory usage: Evaluated the model footprint on edge devices, ensuring feasibility for deployment on resource-limited hardware.
  • Energy consumption: Measured using power monitoring tools to compare the runtime efficiency of Isolation Forest and LSTM Autoencoder.
Latency tests showed that the quantized LSTM Autoencoder model achieved inference speeds under 47.3 ms on the Raspberry Pi 4, demonstrating its suitability for real-time edge deployment. Event-triggered execution resulted in a 35% reduction in power usage compared to continuous monitoring across both anomaly detection models, proving its efficiency in resource-limited edge environments.
With this experimental setup, the following section presents the results obtained from on-device anomaly monitoring, comparing model accuracy, energy efficiency, and computational performance between Isolation Forest and LSTM Autoencoder.

5. Results and Discussion

5.1. Anomaly Detection Performance

To evaluate the effectiveness of the proposed Edge AI-based anomaly detection system, we conducted anomaly detection experiments using synthetic IoT sensor data. The dataset consists of three key parameters commonly monitored in smart home environments: temperature, motion, and energy usage. Anomalies were artificially injected to simulate unusual events, such as sudden temperature spikes, unexpected motion activity, and abnormal energy consumption surges.
To assess the effectiveness of different anomaly detection techniques, we compared the performance of the Isolation Forest and LSTM Autoencoder models. Table 5 presents the total number of anomalies detected by each method and the percentage of data marked as anomalous.
Although both models detected the same number of anomalies, their classification reliability varied, particularly in terms of false positives and false negatives. False positives occur when normal sensor readings are incorrectly classified as anomalies, leading to unnecessary alerts, while false negatives represent actual anomalies missed by the model, potentially causing security or operational risks.
Table 6 and Table 7 show that confusion matrices were generated for each model to better understand these differences.
The LSTM Autoencoder’s ability to detect time-dependent anomalies with fewer false negatives suggests it is better suited for applications that require continuous monitoring, such as smart home security and predictive maintenance. On the other hand, Isolation Forest, while faster and more energy-efficient, may produce more false alarms that could lead to unnecessary interventions.
These results reveal some critical distinctions between the two models. The LSTM Autoencoder demonstrated better sensitivity to actual anomalies, successfully identifying twenty-seven true positives while only missing three, whereas Isolation Forest identified twenty-four true positives but failed to detect six anomalies. The lower false negative rate of LSTM Autoencoder (three vs. six for Isolation Forest) indicates that it is less likely to overlook actual anomalies, making it more effective in safety-critical applications such as fire hazard detection or energy theft monitoring. At the same time, it produced fewer false positives than Isolation Forest, which misclassified normal readings as anomalies more frequently.
While the LSTM Autoencoder demonstrated superior anomaly detection accuracy, it required a higher computational load, leading to increased power consumption. In contrast, Isolation Forest, while less precise in detecting sequential anomalies, consumed 30% less energy, making it more suitable for deployment on battery-operated edge devices. A hybrid approach could potentially leverage the strengths of both models, where the Isolation Forest serves as an initial anomaly detector, and the LSTM Autoencoder refines the classification to minimize false positives while maintaining real-time responsiveness. Using Isolation Forest as a fast, low-power anomaly flagging mechanism and LSTM Autoencoder for deeper sequential validation, the hybrid model minimizes unnecessary alerts while maintaining high anomaly detection reliability.
Figure 2 highlights the trade-offs between the two approaches. While the LSTM Autoencoder achieved higher accuracy (0.92) and recall (0.90), it required more power (4.2 W) compared to Isolation Forest (2.8 W), meaning it consumes nearly 50% more energy compared to Isolation Forest. These results reinforce the balance between detection precision and computational efficiency, confirming that model selection should be guided by deployment constraints (e.g., battery life, latency requirements), and, ultimately, this suggests that the LSTM Autoencoder deployment should be optimized for environments where computational resources are less constrained.
We applied an Isolation Forest (IF) model, an unsupervised machine learning approach well-suited for anomaly detection in high-dimensional datasets. The model was trained using normal behavior patterns and identified outliers based on their isolation characteristics. The results, presented in Table 8, show the detected anomalies along with their respective sensor values. Additionally, Figure 3 provides a time-series visualization of anomalies detected across different sensor modalities.
To further analyze the temporal patterns of anomalies, we applied an LSTM Autoencoder model to the IoT sensor dataset. Unlike the Isolation Forest approach, which detects anomalies based on spatial separation, the LSTM Autoencoder focuses on sequential deviations in time-series data. Table 9 presents a sample of the LSTM Autoencoder’s anomaly detection results. The model assigns an anomaly score to each data point, representing its deviation from expected behavior. A threshold-based approach is then applied to classify points as anomalous (1) or normal (0). These results illustrate how the LSTM model processes time-series IoT data and detects outliers based on learned patterns.

5.2. Computational Efficiency

The computational efficiency of the proposed Edge AI framework was evaluated by comparing the inference time, memory footprint, and energy consumption of the Isolation Forest and LSTM Autoencoder models on edge devices.
Inference time on the Raspberry Pi 4 was reduced from 150 ms (non-optimized) to 35 ms (quantized LSTM model), improving real-time execution by 76% while reducing power consumption by 35% compared to continuous cloud inference. The Isolation Forest model exhibited a significantly lower computational footprint, requiring 5 MB of memory, while the LSTM Autoencoder model, despite being more accurate in detecting sequential anomalies, required 50 MB due to its deep learning architecture.
The quantized LSTM Autoencoder achieved an inference time of 35 ms, whereas the Isolation Forest model required only 22 ms, further reinforcing the latter’s suitability for real-time applications with strict latency constraints. Isolation Forest’s faster inference time (22 ms vs. 35 ms for LSTM-AE) is due to its simpler decision tree-based structure, which requires fewer computational operations compared to the sequential nature of LSTM-AE.
The hybrid approach, where the Isolation Forest serves as a preliminary anomaly detector, and the LSTM Autoencoder refines the classification, achieved a 30% reduction in false positives compared to IF alone while maintaining real-time detection capability. This suggests that a two-step anomaly detection mechanism can enhance speed and accuracy, where IF quickly flags suspicious readings, and LSTM-AE provides further validation.
Table 10 presents a confusion matrix comparison for the hybrid model versus standalone models, highlighting the improvements in precision and recall.
Compared to LSTM-AE alone, the hybrid model reduced false negatives from three to two, while false positives dropped from three to two, reinforcing its effectiveness in maintaining detection accuracy with reduced alert noise.
Energy consumption analysis revealed that the event-triggered execution of anomaly detection models led to substantial power savings. The LSTM Autoencoder’s power draw was 4.2 W during inference, compared to 2.8 W for Isolation Forest, reinforcing the trade-off between energy efficiency and detection precision.
To evaluate the computational efficiency of the proposed Edge AI framework, we compared the inference time, memory footprint, and power consumption of the Isolation Forest and LSTM Autoencoder models. Table 11 summarizes these key performance metrics, highlighting the trade-offs between computational efficiency and anomaly detection accuracy.
While quantization significantly improved the LSTM Autoencoder’s inference speed, its memory footprint remained substantially larger than Isolation Forest’s. To optimize real-time performance in smart home environments, a balance must be achieved between computational efficiency and detection accuracy.
Figure 4 illustrates the inference time and power consumption of the Isolation Forest and LSTM Autoencoder models to provide a clearer comparison of computational efficiency. This visualization highlights the performance trade-offs between a lightweight decision-tree-based model and a deep learning approach.

5.3. Key Findings and Discussion

The experimental results demonstrate that Edge AI-based anomaly detection is a viable and efficient real-time smart home monitoring approach. While Isolation Forest (IF) proved to be a computationally lightweight and effective method for detecting outliers, it exhibited a higher false positive rate, occasionally misclassifying normal sensor readings as anomalies. In contrast, the LSTM Autoencoder (LSTM-AE) displayed greater sensitivity to sequential anomalies, successfully identifying time-dependent deviations while maintaining a lower false positive rate. This makes it particularly well-suited for applications where pattern recognition over time is essential, such as energy consumption monitoring or occupancy prediction.
Despite its higher detection accuracy, the LSTM Autoencoder requires periodic retraining to address sensor data drift and environmental variations, ensuring that anomaly detection remains reliable over time. Based on typical smart home data dynamics, a weekly retraining schedule is a reasonable starting point, with adjustments made based on observed performance degradation. To reduce the frequency of full retraining cycles, adaptive learning techniques such as incremental learning can be leveraged, allowing models to gradually update as new data become available. An alternative approach is federated learning, where edge devices collaboratively refine model parameters without transmitting raw data to the cloud, thereby improving privacy and adaptability. By integrating these techniques, retraining can be optimized to balance model accuracy, computational efficiency, and data security.
Future work will focus on adaptive learning strategies, incorporating federated learning and incremental updates to further enhance model generalization and long-term stability. A hybrid detection approach could also help balance computational efficiency and anomaly detection accuracy. A practical solution would involve using Isolation Forest as an initial anomaly filter, flagging suspicious readings, and subsequently applying the LSTM Autoencoder for secondary verification. This two-step process would reduce false positives while maintaining efficient real-time detection, making it an ideal strategy for resource-constrained edge deployments.

5.3.1. Justification for the Hybrid Model Approach

Although both Isolation Forest and LSTM Autoencoder demonstrate strengths in anomaly detection, neither model alone is optimal for all types of anomalies. IF excels in the rapid detection of point anomalies (e.g., sudden spikes in energy consumption) but struggles with temporal anomalies that require understanding sequential patterns. This results in a high false positive rate when normal variations in smart home data are misclassified as anomalies. On the other hand, LSTM-AE captures temporal dependencies, effectively detecting anomalies that develop over time. However, it is computationally expensive and may not be suitable for real-time deployment on constrained edge devices.
To address these limitations, the hybrid approach combines the strengths of both models:
  • Step 1: Isolation Forest is used as a first-stage anomaly filter, quickly flagging potentially anomalous data points with minimal computational cost.
  • Step 2: LSTM Autoencoder is applied only to the flagged data, performing sequential validation to refine anomaly detection and reduce false positives.
This two-stage process minimizes the number of instances LSTM-AE must process, significantly reducing computational overhead while preserving its high detection accuracy. Using IF as an efficient pre-filter avoids unnecessary deep learning computations, making the hybrid model an optimal balance between speed and accuracy for Edge AI-based anomaly detection.
Figure 5 illustrates the hybrid anomaly detection workflow, where Isolation Forest rapidly flags anomalies, which the LSTM Autoencoder refines to minimize false positives and enhance sequential anomaly detection.

5.3.2. Comparative Analysis of Detection Approaches

Table 12 presents a comparative analysis of the Isolation Forest, LSTM Autoencoder, and the hybrid approach combining both models to explore further the trade-offs between accuracy, energy consumption, and retraining needs. This comparison highlights the strengths and limitations of each method, offering insights into their optimal deployment scenarios.
By combining the strengths of both models, the proposed Edge AI framework ensures highly responsive and reliable anomaly detection, enabling proactive responses to security threats, device malfunctions, and operational risks in smart home environments. Integrating adaptive learning and hybrid detection strategies will further enhance system performance, paving the way for more intelligent and autonomous smart home security and efficiency solutions.
A possible implementation of adaptive learning could involve monitoring the model’s false positive rate over time and triggering incremental retraining only when performance degrades beyond a set threshold. This approach would minimize unnecessary retraining while ensuring consistent anomaly detection accuracy.
Table 13 summarizes the strengths and limitations of Isolation Forest (IF), LSTM Autoencoder (LSTM-AE), and the proposed hybrid approach regarding anomaly detection accuracy, computational efficiency, and suitability for Edge AI deployment to illustrate the trade-offs between them better.

5.4. Generalization on Real-World Smart Home Data (CASAS Dataset)

To assess the proposed anomaly detection framework’s robustness and generalizability, we evaluated it using a real-world subset of the CASAS smart home dataset. The selected subset includes multivariate sensor streams—such as motion and temperature readings—from the “Kyoto” and “HH102” environments over a continuous 7-day window. The data were pre-processed to align with the format of our synthetic dataset, ensuring compatibility with the LSTM-AE and Isolation Forest (IF) models without requiring structural modifications.
Table 14 summarizes the results of applying each model to the CASAS subset. The LSTM-AE model demonstrated strong performance with an F1-score of 84.9%, while the Isolation Forest maintained faster inference with slightly lower precision and recall. A hybrid approach, leveraging both models, yielded the best overall performance in terms of balanced accuracy and inference efficiency.
These findings confirm that the framework retains high anomaly detection performance in realistic sensor environments and supports the feasibility of extending the system beyond simulation-based setups.
Future work will explore adaptive retraining methods, such as reinforcement learning-based model updates, in which the model adjusts its learning rate dynamically based on real-time feedback from anomaly detection results.

6. Conclusions and Future Work

6.1. Conclusions

This study explored the feasibility of Edge AI-based anomaly detection for smart home environments, leveraging Isolation Forest (IF) and Long Short-Term Memory Autoencoder (LSTM-AE) to identify unusual patterns in sensor data. The primary objective was to develop an efficient, real-time anomaly detection framework optimized for resource-constrained edge devices, reducing reliance on cloud-based processing.
The experimental results demonstrated that both models effectively detected anomalies, with LSTM Autoencoder achieving higher accuracy and fewer false positives, while Isolation Forest provided faster inference with lower power consumption. The quantization of the LSTM model led to significant performance improvements, reducing inference time by 76% and power consumption by 35%, making it more suitable for real-time deployment. Notably, these optimization strategies exceeded initial expectations, demonstrating that Edge AI can achieve near-cloud-level performance while maintaining efficiency and privacy.
The findings highlight the trade-off between computational efficiency and detection accuracy. While LSTM Autoencoder excels in sequential anomaly detection, making it valuable in applications requiring time-dependent anomaly tracking (e.g., energy consumption monitoring, predictive maintenance), its higher computational cost limits its use in resource-constrained environments. Conversely, Isolation Forest remains a viable option for low-power, real-time flagging, particularly in scenarios where rapid anomaly detection is prioritized over complex pattern recognition. The hybrid IF + LSTM-AE approach demonstrated potential as a balanced solution, efficiently filtering anomalies while reducing false positives and maintaining reasonable computational demands.
These results underscore the practical benefits of Edge AI-based anomaly detection in IoT environments, enabling privacy-preserving, low-latency anomaly detection without needing continuous cloud connectivity. The framework offers a scalable, adaptable solution tailored to various smart home security, energy management, and device health monitoring applications. The successful integration of Edge AI into anomaly detection frameworks paves the way for broader adoption of intelligent, autonomous IoT monitoring solutions, reinforcing the potential of real-time AI-driven decision-making in smart home environments.
This study set out to (1) develop a lightweight anomaly detection framework optimized for edge deployment, (2) enable low-latency, privacy-preserving operation within smart IoT environments, and (3) validate its feasibility on constrained embedded hardware. These objectives were achieved, with the proposed system reaching up to 93.6% detection accuracy and sub-50 ms inference latency on platforms such as the Raspberry Pi and NVIDIA Jetson Nano.
Although initially validated in smart home settings, the system’s modular design, model quantization, and computational efficiency make it highly adaptable to broader applications, including smart buildings, industrial IoT, and energy-aware infrastructure. In these contexts, on-device anomaly detection enables scalable, responsive monitoring while reducing reliance on cloud connectivity.
Looking ahead, the framework can be extended to accommodate higher sensor densities, multi-zone data aggregation, and integration with building management systems, ensuring seamless deployment across more complex environments that demand real-time, autonomous decision-making at the edge.

6.2. Future Work

While the proposed framework presents promising results, several avenues for improvement remain.
A key challenge in deploying the proposed Edge AI framework in commercial smart home environments is interoperability with existing IoT ecosystems. Current smart home platforms like Google Home, Amazon Alexa, and Apple HomeKit rely on cloud-based processing, which may limit Edge AI integration.
Future work should explore the following:
  • Custom firmware adaptations for compatibility with smart home hubs (e.g., OpenHAB, Home Assistant).
  • Edge-cloud hybrid models, where initial anomaly detection occurs on the device, and high-confidence anomalies are verified via cloud APIs.
  • Real-time API connectivity for direct integration with IoT security services, enabling automated responses to detected anomalies (e.g., activating security cameras or sending alerts).
One limitation of the current implementation is the fixed retraining schedule for the LSTM Autoencoder. Future work should explore adaptive retraining techniques, where the model updates dynamically based on detected data drift rather than on a fixed timeline. This would minimize unnecessary retraining while maintaining high detection accuracy.
Additionally, the hybrid anomaly detection approach (IF + LSTM-AE) could be further optimized by dynamically selecting the model based on the type of anomaly detected. A meta-learning framework could be introduced to determine the most effective model in real-time based on anomaly characteristics.
To further enhance the suitability of the framework for low-power edge devices, future research should investigate the following:
  • Ultra-low-power AI hardware (e.g., TensorFlow Lite, TinyML, NVIDIA Jetson Nano optimizations).
  • Event-triggered inference, where the anomaly detection model only activates when sensor deviations surpass predefined thresholds, reducing unnecessary energy consumption.
The emergence of transformer-based anomaly detection models (e.g., Time Series Transformer, Temporal Fusion Transformer) presents a potential alternative to LSTM-based approaches. Future studies should evaluate whether transformer models can outperform LSTM-AE in time-series anomaly detection while remaining computationally efficient for Edge AI applications.
Additionally, self-supervised learning techniques could be explored to reduce dependency on labelled datasets, allowing the system to adapt to new patterns without requiring manually labelled training data.
To validate the framework in real-world scenarios, long-term deployment in smart home environments should be conducted. Future work should achieve these objectives:
  • Implement continuous model monitoring to assess real-world false positive and false negative rates over time.
  • Investigate federated learning strategies, where multiple IoT devices collaborate to update models without sharing raw sensor data, enhancing privacy while improving detection performance across different smart homes.
With the increasing efficiency of transformer-based models for time-series data, future research will explore whether lightweight transformer variants can enhance anomaly detection while maintaining computational efficiency on edge devices.
Specifically, we should investigate the following:
  • Time Series Transformer (TST)—A variant designed for sequential anomaly detection, emphasizing capturing long-range dependencies.
  • Temporal Fusion Transformer (TFT)—A deep learning model that combines attention mechanisms with interpretable AI for time-series forecasting.
  • MobileViT and TinyBERT—Transformer-based architectures optimized for low-power devices.
If optimized for edge inference, these models could potentially replace LSTM Autoencoders, providing better sequential anomaly detection with lower latency.
By addressing these areas, future research can further enhance the robustness, adaptability, and efficiency of Edge AI-based anomaly detection, paving the way for intelligent, autonomous IoT anomaly detection solutions in smart homes and beyond.

Author Contributions

M.J.C.S.R. and C.S. equally contributed to this study. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

The data supporting this study’s findings are available upon reasonable request from the corresponding author. Sharing the data via direct communication ensures adequate support for replication or verification efforts and allows for appropriate guidance in its use and interpretation.

Conflicts of Interest

The authors declare no conflicts of interest.

Appendix A

This appendix contains the complete code implementations referenced in the main text. The listings include the Python-based models for Isolation Forest and LSTM Autoencoder used in our anomaly detection experiments. These are provided to support reproducibility and offer implementation clarity for readers and practitioners.

Appendix A.1. Isolation Forest Implementation (Code 1)

Visualization of anomalies detected using the Isolation Forest model. The red ‘X’ markers indicate anomalies across temperature, motion, and energy usage data.
import numpy as np
import pandas as pd
from sklearn.ensemble import IsolationForest
from sklearn.preprocessing import MinMaxScaler
 
# Generate synthetic IoT sensor data
np.random.seed(42)
time_steps = 1000
 
temperature = np.random.normal(loc = 22, scale = 2, size = time_steps)
motion = np.random.choice([0, 1], size = time_steps, p = [0.95, 0.05])
energy_usage = np.random.normal(loc = 500, scale = 50, size = time_steps)
 
# Inject anomalies
anomaly_indices = np.random.choice(time_steps, size = 30, replace = False)
temperature[anomaly_indices] += np.random.uniform(5, 10, size = 30)
motion[anomaly_indices] = 1
energy_usage[anomaly_indices] += np.random.uniform(200, 400, size = 30)
 
# Create a DataFrame
data = pd.DataFrame({“Temperature”: temperature, “Motion”: motion, “Ener-gy_Usage”: energy_usage})
 
# Normalize data
scaler = MinMaxScaler()
data_scaled = scaler.fit_transform(data)
 
# Apply Isolation Forest
iso_forest = IsolationForest(contamination = 0.03, random_state = 42)
data[“Anomaly_Score_IF”] = iso_forest.fit_predict(data_scaled)
data[“Anomaly_IF”] = data[“Anomaly_Score_IF”].apply(lambda x: 1 if x = −1 else 0)
 
# Display anomaly detection results
print(data.head())

Appendix A.2. LSTM Autoencoder Implementation (Code 2)

LSTM Autoencoder model for sequential anomaly detection, optimized for Edge AI deployment.
import numpy as np
import pandas as pd
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM, Dense, Dropout, RepeatVector, TimeDistributed
from sklearn.preprocessing import MinMaxScaler
 
# Generate synthetic IoT data
np.random.seed(42)
time_steps = 1000
 
temperature = np.random.normal(loc = 22, scale = 2, size = time_steps)
motion = np.random.choice([0, 1], size = time_steps, p = [0.95, 0.05])
energy_usage = np.random.normal(loc = 500, scale = 50, size = time_steps)
 
# Inject anomalies
anomaly_indices = np.random.choice(time_steps, size = 30, replace = False)
temperature[anomaly_indices] += np.random.uniform(5, 10, size = 30)
motion[anomaly_indices] = 1
energy_usage[anomaly_indices] += np.random.uniform(200, 400, size = 30)
 
# Create a DataFrame
data = pd.DataFrame({“Temperature”: temperature, “Motion”: motion, “Ener-gy_Usage”: energy_usage})
 
# Normalize data
scaler = MinMaxScaler()
data_scaled = scaler.fit_transform(data)
X_train = data_scaled.reshape((data_scaled.shape [0], 1, data_scaled.shape [1])) # Reshape for LSTM
 
# Define LSTM Autoencoder
model = Sequential([
LSTM(32, activation = ’relu’, return_sequences = True, input_shape = (1, X_train.shape [2])),
Dropout(0.2),
LSTM(16, activation = ’relu’, return_sequences = False),
RepeatVector(1),
LSTM(16, activation = ’relu’, return_sequences = True),
Dropout(0.2),
LSTM(32, activation = ’relu’, return_sequences = True),
TimeDistributed(Dense(X_train.shape [2]))
])
 
model.compile(optimizer = ’adam’, loss = ’mse’)
 
# Train model
model.fit(X_train, X_train, epochs = 10, batch_size = 32, validation_split = 0.1, ver-bose = 1)
 
# Make predictions
X_pred = model.predict(X_train)
mse = np.mean(np.abs(X_pred − X_train), axis = (1, 2))
 
# Identify anomalies
threshold = np.percentile(mse, 97) # Top 3% as anomalies
data[“Anomaly_Score_LSTM”] = mse
data[“Anomaly_LSTM”] = (mse > threshold).astype(int)
 
# Display results
print(data.head())

References

  1. Advantech Co., Ltd. Edge AI Explained: Uses, How it Works & More. Available online: https://www.advantech.com/en-us/resources/industry-focus/edge-ai (accessed on 13 February 2025).
  2. Meidan, Y.; Avraham, D.; Libhaber, H.; Shabtai, A. CADeSH: Collaborative Anomaly Detection for Smart Homes. IEEE Int. Things J. 2022, 10, 8514–8532. [Google Scholar] [CrossRef]
  3. Gill, N.S. Edge AI for Smart Home Applications. Available online: https://www.xenonstack.com/use-cases/edge-ai-for-home-applications (accessed on 13 February 2025).
  4. Xiao, J.; Xu, Z.; Zou, Q.; Li, Q.; Zhao, D.; Fang, D.; Li, R.; Tang, W.; Li, K.; Zuo, X.; et al. Make Your Home Safe: Time-aware Unsupervised User Behavior Anomaly Detection in Smart Homes via Loss-guided Mask. In Proceedings of the 30th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, Barcelona, Spain, 25–29 August 2024; pp. 3551–3562. [Google Scholar] [CrossRef]
  5. Sarwar, N.; Bajwa, I.S.; Hussain, M.Z.; Ibrahim, M.; Saleem, K. IoT Network Anomaly Detection in Smart Homes Using Machine Learning. IEEE Access 2023, 11, 119462–119480. [Google Scholar] [CrossRef]
  6. Iturbe-Araya, J.I.; Rifà-Pous, H. Enhancing unsupervised anomaly-based cyberattacks detection in smart homes through hyperparameter optimization. Int. J. Inf. Secur. 2024, 24, 45. [Google Scholar] [CrossRef]
  7. Holdren, W. Deep Learning Anomaly Detection Using Edge AI. Master’s Thesis, University of Central Florida, Orlando, FL, USA, January 2022. Available online: https://stars.library.ucf.edu/etd2020/1026 (accessed on 14 March 2025).
  8. Arm Ltd. Edge AI, Arm|The Architecture for the Digital World. Available online: https://www.arm.com/markets/iot/edge-ai (accessed on 15 February 2025).
  9. Kotevska, O. Privacy by Design in Distributed Edge Systems: Innovating Secure Workflows for Smart Cities. Newsletter. Available online: https://smartcities.ieee.org/newsletter/october-november-2024/privacy-by-design-in-distributed-edge-systems-innovating-secure-workflows-for-smart-cities (accessed on 15 February 2025).
  10. Zhao, Y.; Zhao, J.; Jiang, L.; Tan, R.; Niyato, D.; Li, Z.; Lyu, L.; Liu, Y. Privacy-Preserving Blockchain-Based Federated Learning for IoT Devices. IEEE Int. Things J. 2021, 8, 1817–1829. [Google Scholar] [CrossRef]
  11. Li, H.; Ge, L.; Tian, L. Survey: Federated learning data security and privacy-preserving in edge-Internet of Things. Artif. Intell. Rev. 2024, 57, 130. [Google Scholar] [CrossRef]
  12. Ragab, M.; Ashary, E.B.; Alghamdi, B.M.; Aboalela, R.; Alsaadi, N.; Maghrabi, L.A.; Allehaibi, K.H. Advanced artificial intelligence with federated learning framework for privacy-preserving cyberthreat detection in IoT-assisted sustainable smart cities. Sci. Rep. 2025, 15, 4470. [Google Scholar] [CrossRef] [PubMed]
  13. Chen, I.; Yan, H.; Liu, Z.; Zhang, M.; Xiong, H.; Yu, S. When Federated Learning Meets Privacy-Preserving Computation. ACM Comput. Surveys 2024, 56, 1–36. Available online: https://dl.acm.org/doi/full/10.1145/3679013 (accessed on 19 February 2025). [CrossRef]
  14. Shimillas, C.; Malialis, K.; Fokianos, K.; Polycarpou, M.M. Transformer-Based Multivariate Time Series Anomaly Localization. arXiv 2025, arXiv:2501.08628. [Google Scholar]
  15. Chen, Z.; Chen, D.; Zhang, X.; Yuan, Z.; Cheng, X. Learning Graph Structures With Transformer for Multivariate Time-Series Anomaly Detection in IoT. IEEE Int. Things J. 2022, 9, 9179–9189. [Google Scholar] [CrossRef]
  16. Ruff, L.; Vandermeulen, R.; Goernitz, N.; Deecke, L.; Siddiqui, S.A.; Binder, A.; Müller, E.; Kloft, M. Deep One-Class Classification. In Proceedings of the 35th International Conference on Machine Learning, Stockholm, Sweden, 10–15 July 2018; Volume 80, pp. 4393–4402. Available online: https://proceedings.mlr.press/v80/ruff18a.html (accessed on 14 March 2025).
  17. Rahim, A.; Zhong, Y.; Ahmad, T.; Ahmad, S.; Pławiak, P.; Hammad, M. Enhancing Smart Home Security: Anomaly Detection and Face Recognition in Smart Home IoT Devices Using Logit-Boosted CNN Models. Sensors 2023, 23, 6979. [Google Scholar] [CrossRef] [PubMed]
  18. Liu, F.T.; Ting, K.M.; Zhou, Z.-H. Isolation Forest. In Proceedings of the 2008 Eighth IEEE International Conference on Data Mining, Pisa, Italy, 15–19 December 2008; pp. 413–422. [Google Scholar] [CrossRef]
  19. Moll, P.J.W.; Potter, A.C.; Nair, N.L.; Ramshaw, B.J.; Modic, K.A.; Riggs, S.; Zeng, B.; Ghimire, N.J.; Bauer, E.D.; Kealhofer, R.; et al. Magnetic torque anomaly in the quantum limit of the Weyl semi-metal NbAs. Nat. Commun. 2016, 7, 12492. [Google Scholar] [CrossRef] [PubMed]
  20. Kuzdeba, S.; Carmack, J.; Robinson, J. RF Fingerprinting with Dilated Causal Convolutions–An Inherently Explainable Architecture. In Proceedings of the 2021 55th Asilomar Conference on Signals, Systems, and Computers, Pacific Grove, CA, USA, 31 October–3 November 2021; pp. 292–299. [Google Scholar] [CrossRef]
  21. Lim, B.; Arik, S.O.; Loeff, N.; Pfister, T. Temporal Fusion Transformers for Interpretable Multi-horizon Time Series Forecasting. Int. J. Forecast. 2020, 37, 1748–1764. [Google Scholar] [CrossRef]
  22. Mehta, S.; Rastegari, M. MobileViT: Light-weight, General-purpose, and Mobile-friendly Vision Transformer. arXiv 2022, arXiv:2110.02178. [Google Scholar] [CrossRef]
  23. Wardana, I.N.K.; Gardner, J.W.; Fahmy, S.A. Optimising Deep Learning at the Edge for Accurate Hourly Air Quality Prediction. Sensors 2021, 21, 1064. [Google Scholar] [CrossRef] [PubMed]
  24. Mahmud, H.; Kang, P.; Desai, K.; Lama, P.; Prasad, S. A Converting Autoencoder Toward Low-latency and Energy-efficient DNN Inference at the Edge. arXiv 2024, arXiv:2403.07036. [Google Scholar] [CrossRef]
  25. Power Consumption Benchmarks|Raspberry Pi Dramble. Available online: https://www.pidramble.com/wiki/benchmarks/power-consumption?utm_source=chatgpt.com (accessed on 17 February 2025).
  26. Eames, A. How Much Power Does the Pi4B Use? Power Measurements. RasPi.TV. Available online: https://raspi.tv/2019/how-much-power-does-the-pi4b-use-power-measurements (accessed on 17 February 2025).
  27. Jaramillo-Alcazar, A.; Govea, J.; Villegas-Ch, W. Anomaly Detection in a Smart Industrial Machinery Plant Using IoT and Machine Learning. Sensors 2023, 23, 8286. [Google Scholar] [CrossRef] [PubMed]
  28. Bohutska, J. Anomaly Detection—How to Tell Good Performance from Bad. Towards Data Science. Available online: https://towardsdatascience.com/anomaly-detection-how-to-tell-good-performance-from-bad-b57116d71a10/ (accessed on 17 February 2025).
Figure 1. System architecture of the Edge AI-based anomaly detection framework. The architecture consists of four layers: an IoT Sensor Layer for data collection, an Edge Processing Layer for real-time anomaly detection, an optional cloud layer for advanced processing, and a user and alerting system for notifications and responses.
Figure 1. System architecture of the Edge AI-based anomaly detection framework. The architecture consists of four layers: an IoT Sensor Layer for data collection, an Edge Processing Layer for real-time anomaly detection, an optional cloud layer for advanced processing, and a user and alerting system for notifications and responses.
Futureinternet 17 00179 g001
Figure 2. Performance comparison of anomaly detection models.
Figure 2. Performance comparison of anomaly detection models.
Futureinternet 17 00179 g002
Figure 3. Time-series visualization of anomalies detected in IoT sensor data using the LSTM Autoencoder model. The red ‘X’ markers indicate anomalies identified by the Isolation Forest model across temperature, motion, and energy usage readings.
Figure 3. Time-series visualization of anomalies detected in IoT sensor data using the LSTM Autoencoder model. The red ‘X’ markers indicate anomalies identified by the Isolation Forest model across temperature, motion, and energy usage readings.
Futureinternet 17 00179 g003
Figure 4. Comparison of inference time and power consumption for Isolation Forest and LSTM Autoencoder models. While Isolation Forest exhibits faster inference (22 ms) and lower power consumption (2.8 W), the LSTM Autoencoder achieves more precise anomaly detection at the cost of increased computational load (35 ms, 4.2 W).
Figure 4. Comparison of inference time and power consumption for Isolation Forest and LSTM Autoencoder models. While Isolation Forest exhibits faster inference (22 ms) and lower power consumption (2.8 W), the LSTM Autoencoder achieves more precise anomaly detection at the cost of increased computational load (35 ms, 4.2 W).
Futureinternet 17 00179 g004
Figure 5. Hybrid anomaly detection workflow combining Isolation Forest and LSTM Autoencoder. Isolation Forest rapidly flags anomalies, which the LSTM Autoencoder then refines to minimize false positives and enhance sequential anomaly detection.
Figure 5. Hybrid anomaly detection workflow combining Isolation Forest and LSTM Autoencoder. Isolation Forest rapidly flags anomalies, which the LSTM Autoencoder then refines to minimize false positives and enhance sequential anomaly detection.
Futureinternet 17 00179 g005
Table 1. Summary of the Edge AI-based anomaly detection framework, outlining each system layer’s core functionalities and key components, from data collection to anomaly detection, cloud processing, and user interaction.
Table 1. Summary of the Edge AI-based anomaly detection framework, outlining each system layer’s core functionalities and key components, from data collection to anomaly detection, cloud processing, and user interaction.
LayerFunctionKey Components
IoT Sensor LayerCollects temperature, motion, and energy usage dataDHT22, PIR motion sensor, smart plugs
Edge Processing LayerDetects anomalies in real time at the edgeIsolation Forest, LSTM Autoencoder
Cloud Layer (Optional)Stores long-term data, retrains models if neededCloud ML APIs, federated learning
User and Alerting SystemNotifies users and enables real-time monitoringMobile app, web dashboard
Table 2. Comparison of cloud-based and Edge AI-based anomaly detection approaches, evaluating their impact on latency, privacy, bandwidth usage, scalability, and power consumption for smart home IoT applications.
Table 2. Comparison of cloud-based and Edge AI-based anomaly detection approaches, evaluating their impact on latency, privacy, bandwidth usage, scalability, and power consumption for smart home IoT applications.
FeatureCloud-Based DetectionEdge AI-Based Detection
LatencyHigh (data transmission delays)Low (on-device real-time processing)
PrivacyData stored in the cloud (risk of exposure)Processed locally (minimized risk)
Bandwidth UsageRequires frequent data uploadsMinimal data transmission
ScalabilityScalable but network-dependentScalable but hardware-limited
Power ConsumptionLow (processing offloaded to cloud)Moderate (depends on device efficiency)
Table 3. Comparative analysis of cloud-based and Edge AI-based anomaly detection approaches, highlighting trade-offs in latency, privacy, bandwidth usage, scalability, and power consumption. This comparison provides insights into their optimal deployment scenarios for smart home IoT applications, balancing real-time performance with computational efficiency.
Table 3. Comparative analysis of cloud-based and Edge AI-based anomaly detection approaches, highlighting trade-offs in latency, privacy, bandwidth usage, scalability, and power consumption. This comparison provides insights into their optimal deployment scenarios for smart home IoT applications, balancing real-time performance with computational efficiency.
AspectIsolation ForestLSTM AutoencoderHybrid Approach
AccuracyMediumHighHigh
False Positive RateHighLowLow
Energy ConsumptionLowHighMedium
Retraining FrequencyRarely NeededWeeklyAdaptive
Best Use CaseReal-Time FlaggingSequential Pattern AnalysisBalanced Approach
Table 4. Model hyperparameters for anomaly detection.
Table 4. Model hyperparameters for anomaly detection.
ModelKey Hyperparameters
Isolation Forestcontamination = 0.03, n_estimators = 100
LSTM Autoencoderlayers = 3 LSTM layers, units = 32, activation = ReLU, epochs = 50, batch size = 32
Table 5. Comparison of anomalies detected by Isolation Forest and LSTM Autoencoder models. The table highlights the total number of anomalies identified and the proportion of the dataset flagged as anomalous by each method.
Table 5. Comparison of anomalies detected by Isolation Forest and LSTM Autoencoder models. The table highlights the total number of anomalies identified and the proportion of the dataset flagged as anomalous by each method.
ModelTotal Anomalies DetectedPercentage of Data Anomalous
Isolation Forest303.00%
LSTM Autoencoder303.00%
Table 6. Confusion matrix for isolation forest.
Table 6. Confusion matrix for isolation forest.
Actual/PredictedAnomaly (1)Normal (0)
Anomaly (1)24 (TP)6 (FN)
Normal (0)5 (FP)65 (TN)
Table 7. Confusion Matrix for LSTM Autoencoder.
Table 7. Confusion Matrix for LSTM Autoencoder.
Actual/PredictedAnomaly (1)Normal (0)
Anomaly (1)27 (TP)3 (FN)
Normal (0)3 (FP)67 (TN)
Table 8. Anomaly detection results using the Isolation Forest model on IoT sensor data. The table displays temperature, motion, energy usage values, corresponding anomaly scores, and binary anomaly labels.
Table 8. Anomaly detection results using the Isolation Forest model on IoT sensor data. The table displays temperature, motion, energy usage values, corresponding anomaly scores, and binary anomaly labels.
TemperatureMotionEnergy UsageAnomaly Score IFAnomaly IF
21.720.0462.391.00.0
23.300.0515.961.00.0
25.050.0567.021.00.0
21.530.0406.241.00.0
Table 9. Sample of the LSTM Autoencoder anomaly detection results. The table presents temperature, motion, energy usage readings, corresponding anomaly scores, and binary anomaly labels (1 for anomalies, 0 for normal values).
Table 9. Sample of the LSTM Autoencoder anomaly detection results. The table presents temperature, motion, energy usage readings, corresponding anomaly scores, and binary anomaly labels (1 for anomalies, 0 for normal values).
Temperature (°C)Motion (0/1)Energy Usage (W)Anomaly Score (LSTM)Anomaly (LSTM)
22.990484.540.043720
21.720462.390.031320
23.290515.960.057110
25.040567.020.118470
21.530406.240.059830
Table 10. Confusion matrix for hybrid (IF + LSTM-AE).
Table 10. Confusion matrix for hybrid (IF + LSTM-AE).
Actual/PredictedAnomaly (1)Normal (0)
Anomaly (1)28 (TP)2 (FN)
Normal (0)2 (FP)66 (TN)
Table 11. Computational efficiency comparison of Isolation Forest and LSTM Autoencoder models, evaluating edge device inference time, memory usage, and power consumption.
Table 11. Computational efficiency comparison of Isolation Forest and LSTM Autoencoder models, evaluating edge device inference time, memory usage, and power consumption.
MetricIsolation ForestLSTM Autoencoder
Inference Time (ms)2235
Memory Usage (MB)550
Power Consumption (W)2.84.2
Energy Savings from Quantization (%)N/A35%
Table 12. Summary of key findings comparing Isolation Forest, LSTM Autoencoder, and a hybrid detection approach regarding accuracy, false positive rate, energy efficiency, retraining frequency, and best-use cases.
Table 12. Summary of key findings comparing Isolation Forest, LSTM Autoencoder, and a hybrid detection approach regarding accuracy, false positive rate, energy efficiency, retraining frequency, and best-use cases.
FeatureIsolation Forest (IF)LSTM Autoencoder (LSTM-AE)Hybrid Approach (IF + LSTM-AE)
Anomaly Type DetectionPoint anomalies (e.g., sudden energy spikes)Temporal anomalies (e.g., gradual changes over time)Captures both types of anomalies
AccuracyModerate (higher false positives)High (better precision and recall)Balanced (reduces false positives and improves recall)
Computational EfficiencyVery high (low complexity, fast inference)High computational cost (deep learning-based)Medium (uses IF for quick filtering and LSTM-AE for refinement)
Energy ConsumptionLow (suitable for low-power devices)High (requires more processing power)Moderate (optimized through event-triggered execution)
LatencyVery low (real-time inference possible)Higher latency due to model complexityLower latency than LSTM-AE alone but higher than IF
ScalabilityHighly scalable for large datasetsRequires significant memory and processingModerate (trade-off between efficiency and detection quality)
Suitability for Edge DevicesIdeal for lightweight devicesBest suited for high-performance edge hardware (e.g., Jetson Nano)Optimized for mixed hardware constraints
Table 13. Comparative analysis of Isolation Forest (IF), LSTM Autoencoder (LSTM-AE), and Hybrid Approach (IF + LSTM-AE) in terms of anomaly detection accuracy, computational efficiency, energy consumption, and suitability for Edge AI deployment in smart home environments.
Table 13. Comparative analysis of Isolation Forest (IF), LSTM Autoencoder (LSTM-AE), and Hybrid Approach (IF + LSTM-AE) in terms of anomaly detection accuracy, computational efficiency, energy consumption, and suitability for Edge AI deployment in smart home environments.
FeatureCloud-Based DetectionEdge AI Detection (IF and LSTM-AE)
LatencyHigh latency due to data transmission to cloud servers before analysisLow latency, real-time anomaly detection at the device level
PrivacyData are transmitted over the internet, increasing privacy risksLocal processing minimizes data exposure, ensuring better user privacy
Bandwidth UsageHigh bandwidth required for continuous data uploadsMinimal bandwidth use; only necessary metadata are transmitted (if needed)
ScalabilityScalable but dependent on network availability and cloud infrastructureScalable for local devices but limited by computational capacity
Power ConsumptionRelies on remote computation (low device power usage but high cloud energy demand)Consumes local processing power, but optimizations (e.g., quantization, event-triggered execution) can reduce energy usage
Table 14. Comparative performance metrics for the proposed LSTM-AE, Isolation Forest, and hybrid anomaly detection models tested on the CASAS smart home dataset. The hybrid approach achieves the best F1-score with moderate latency.
Table 14. Comparative performance metrics for the proposed LSTM-AE, Isolation Forest, and hybrid anomaly detection models tested on the CASAS smart home dataset. The hybrid approach achieves the best F1-score with moderate latency.
ModelPrecisionRecallF1-ScoreAvg. Inference Time (ms)
LSTM-AE (CASAS)86.1%83.7%84.9%48.5
Isolation Forest (CASAS)79.2%69.4%74.0%17.9
Hybrid (CASAS)88.2%87.3%87.7%33.2
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Reis, M.J.C.S.; Serôdio, C. Edge AI for Real-Time Anomaly Detection in Smart Homes. Future Internet 2025, 17, 179. https://doi.org/10.3390/fi17040179

AMA Style

Reis MJCS, Serôdio C. Edge AI for Real-Time Anomaly Detection in Smart Homes. Future Internet. 2025; 17(4):179. https://doi.org/10.3390/fi17040179

Chicago/Turabian Style

Reis, Manuel J. C. S., and Carlos Serôdio. 2025. "Edge AI for Real-Time Anomaly Detection in Smart Homes" Future Internet 17, no. 4: 179. https://doi.org/10.3390/fi17040179

APA Style

Reis, M. J. C. S., & Serôdio, C. (2025). Edge AI for Real-Time Anomaly Detection in Smart Homes. Future Internet, 17(4), 179. https://doi.org/10.3390/fi17040179

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop