Submitted:
21 October 2026
Posted:
23 October 2026
You are already at the latest version
Abstract
The Internet of Things (IoT) offers benefits in smart homes, healthcare, and industry but introduces security challenges for devices with limited processing power, memory, and energy. This study proposes a framework combining anomaly detection with adaptive security protocol recommendations to balance protection and resource use. Data preprocessing includes cleaning, normalization, outlier detection, and the Synthetic Minority Oversampling Technique (SMOTE) for class balancing. A Random Forest classifier identifies normal and anomalous device behavior, while a feedback-based recommendation system selects security protocols according to observed behavior and available device resources. The framework was evaluated using the Smart LED Light dataset and achieved 97.52% accuracy, 97.48% precision, 97.56% recall, and a 97.52% F1-score. These results indicate effective anomaly detection and support the proposed integration of classification with resource-aware security protocol recommendations for constrained IoT environments.
Keywords:
Internet of Things
; anomaly detection
; random forest
; SMOTE
; security protocol recommendation
; resource-constrained devices
1. Introduction
IoT devices, especially in smart homes, industries, and healthcare have their immense potential benefits but their security risks are huge [1]. These devices are limited in their resource capabilities, which makes it complicated to construct a security algorithm that can accommodate an intensive security system while still not oversimplifying and putting the device at risk [2]. Combined with this resource restriction, there is a demand for dynamic, personalized and efficient resource-saving security policies appropriate for IoT devices [3]. The proposed security framework will address this lack of protection by harnessing the capabilities of an intelligent recommender engine system which will accept and recommend security policies on the IoT devices and how they adapt to their ability to self-protect based on their resource availability and specific behaviour [4].
The limited resources which a system relies on are the first aspect that creates issues of security for IoT devices since they are resource-constrained devices and not designed or built to run conventional security mechanisms that require assets [5]. Additionally, the variances of devices within an IoT ecosystem complicate the situation (e.g. the variances of processing power, memory and batteries)[6]. These types of limitations allow advantages to cyberattack such as data breaches and Denial of Service (DoS) attacks that could be detrimental [7]. Thus, the need is to enable understanding and combat this type of limitation to implement a sustainable security mechanism to the best of performance against deficiencies and types of threats that could likely still exist within the same IoT context will be explored [8].
Security solutions for IoT devices are generally security protocols based on lightweight security or AD like lightweight encryption, intrusion detection systems (IDS), and machine learning (ML) based AD [9]. Existing solutions that are meant to achieve a balance between the resource-constrained environment with the need for security are fairly well known at this point, such as AES encryption, ECC, and token-based [10]. Unfortunately, the existing evaluations of these protocols do not always adequately address the real-time implementation or the user specific security concerns [11]. Moreover, not all the protocols presented use resources efficiently or provide an adequate level of security, which further adds to the performance variability of the resource constrained environment [12].
The suggested framework eliminates these weaknesses by combinatorically incorporating real-time AD with adaptive security protocol suggestions in regard to the prevailing resource state of IoT gadgets. The system uses the foundations of AD and the capabilities of the available resources to select security protocols, which could be lightweight or stronger, each time based on the detected anomalies that it implements. The technical particularity of the proposed research is that security measures will be implemented dynamically so that the IoT devices can be safe without affecting their performance or their resource consumption. The key contribution of this paper:
- Uses real-time AD with a dynamic system to suggest security policies to resource-constrained IoT devices.
- Apply data cleaning, missing value processing, outlier detection, feature scaling, normalization, plus SMOTE-based class balancing to guarantee high-quality training data.
- Accurately uses the Random Forest algorithm with bootstrapping and majority voting to determine whether IoT device behavior is normal or not.
- Uses a feedback-based system to choose the right security protocol (e.g. AES, ECC) based on device resources and identified anomalies.
- Guarantees security and does not overload devices and offers a framework, which can be extended to various IoT settings and data.
The structure is as follows: Section 2, literature review of challenges and solutions in existence in field of AD and security protocol adaptation in IoT devices. Section 3 proposed research methodology, such as preprocessing of data, identification of anomalies through use of Random Forest, and a security protocol recommendation system that is based on feedback. Section 4 gives results and discussion section where performance of framework is evaluated using various assessment metrics. And lastly, Section 5 ends the study by summarizing main findings and future research.
2. Literature Survey
2.1. Security Challenges in Resource-Constrained IoT Devices
Radhakrishnan et al., [13] present the emergence of IoT has increased the security issues and led to the discussion of lightweight cryptography (LWC) solutions to tackle the problems of privacy and confidentiality. Other LWC algorithms include AES-128, SPECK and ASCON that have been extensively researched due to their suitability in resource constrained IoT environment. The literature presents the need to examine these algorithms for their execution time, memory consumption, and level of protection to arrive at the optimum compromise between performance and security of the IoT devices. Alwaisi et al., [14] described the increased complexity of cyber-attacks on IoT networks specifically with respect to resource-constrained devices has initiated studies on Tiny ML (TinyML) to improve security. The IoT devices, which make up edge and cloud computing, necessitate use of effective ML to identify and classify resource-constrained attacks. This paper examines different ML architectures, such as cloud-based, edge-based, and device-based solutions, to evaluate their energy usage, memory usage, and detection, and emphasize improving security of embedded IoT devices.
Tanksale,[15] presents that emergence of IoT has made it essential to provide secure communication between resource-constrained devices. ECDH key exchange is highly secure and computationally efficient, thus, a potential solution to IoT. In this paper, ECDH implementation problems and opportunities of applying ECDH to embedded systems are discussed often in terms of memory, processing power, and energy constraints optimization methods. It also examines different elliptic curves and offers suggestions on how to achieve a better security level without compromising the performance of the IoT devices. Hegde & Maddikunta, [16] presents the implementation of Blockchain and IoT (BCIoT) in medical care and intends to overcome the main challenges of IoT-based medical services, which include security and privacy of data, interoperability, and scalability. This paper surveys the prevailing BCIoT techniques toward remote patient monitoring, electronic health records management, health asset tracking, and the contact tracking of COVID-19 patients. The paper examines the enabling platforms, uses and explains how BCIoT can improve healthcare services to be better patient care and overcome system constraints.
2.2. Intrusion and AD in IoT Environments
Bhavsar et al., [17] present that Industrial IoT finds application in many industrial fields, and its security is a great issue because the communication protocols are prone to attacks. IoT devices are normally immune to traditional security systems like signature and rule-based systems. This paper will describe the building of an IDS founded on a DL framework: Pearson-Correlation Coefficient - Convolutional-Networks (PCC-CNN) for network anomaly detection. The method integrates linear feature extraction with DL to maximize anomaly detection and attack classification. Antonius et al., [18] describes fast proliferation of IoT devices which has led to new threats to system security, especially network anomaly detection in the IoT environment. Traditional approaches suffer from resource constraints and dynamic behavior in an IoT network. In this paper, a new Bat-optimized is proposed, with a hybrid CNN for spatial feature extraction for temporal patterns, improved by the Bat algorithm to enhance anomaly detection performance.
Rafique et al., [19] mentioned that IoT has brought with it a number of security challenges, especially in detection of anomalies. The systems based on AI can improve process of AD by detecting multiple types of threats in IoT context, including brute force, DDoS, and SQL injection attacks. Analyses the applications of ML and DL in area of IoT AD with a focus on challenges of large attack surface and necessity of additional scaling, testing in real-time, and heterogeneous datasets. Zohourian et al. [20] present massive proliferation of IoT devices in different sectors has added immense security pressure to them because resource limitations and insufficient security features to counter-research threats. IDS have been suggested to overcome the threats of IoT, but it is not practically adopted because of its dependence on labeled data and the high cost of computation. The system mentioned in work is IoT-PRIDS, which is a lightweight, non-ML-based IDS framework that uses packet representations for monitoring behavior of devices, and thus it is a possible contender for securing IoT space.
2.3. Lightweight ML for IoT Security
Ismail et al., [21] mentioned that Cyber-attacks are a major threat to IoT sensor networks and it is necessary to have effective security mechanisms that address constraints of these networks. In this paper, it is suggested to use a framework of security that integrates blockchain and ML to safeguard the IoT networks. A blockchain prevention component of identity and trust management through smart contracts and an ML detection component through the Light Gradient Boosting Machine (LightGBM) to distinguish malicious nodes. In this regard, study compares different ML algorithms to identify most effective algorithm. Javed et al., [22] present IoT devices in smart homes are convenient but have security and privacy risks because they have limited processing capabilities. ML based IDS are deployed in cloud and edge yet are not generally integrated into the device in IoT. The present paper suggests a new two-layer IDS, where the first layer will be running on a smart thermostat based on a microcontroller and the second layer will be running on cloud to classify attacks. The strategy will enhance accuracy in detection and efficiency in computation at smart home settings.
Sadhwani et al., [23] present issue of security of lightweight IoT networks that are susceptible to DDoS attacks because of the insufficient resources. It concentrates on creating a light IDS whose design is built upon ML classifiers and a new way of pre-processing data. This paper provides an accent on importance of dealing with missing data, feature elimination, and AD and balancing datasets with SMOTE. The performance of different classifiers, such as logistic regression, the random forest, and the naive Bayes, is tested against their ability to identify DDoS and other attacks in IoT-based environment. Ankita et al., [24] discuss security issues of Industry 4.0, in which heterogeneous devices produce a huge volume of data. It suggests a framework on how to identify different forms of attacks based on a DL, which involves CNN and Long Short-Term Memory (LSTM). To classify attacks using UNSW-NB15 dataset to offer security to sensors in industrial settings. It uses Cortex processors, Python 3.8.8 and Keras to construct, comprising of convolutional and max pooling and dense layers.
2.4. Adaptive Security Protocols and Recommendation Systems
Ferreira et al., [25] described application of Recommender Systems in Cybersecurity is discussed in this paper to help human operators deal with cyberattacks. These systems are associated with decision-making by filtering and prioritizing information, overload reduction, and efficiency. The survey evaluates different works in which Recommender Systems were used in Cybersecurity, demonstrating a possibility of improvement of attack detection, prevention, and incident management. It also talks about future research directions which consist in incorporation of Recommender Systems into security management systems as well as response applications with the aim of simplifying and enhancing results. Gligorea et al., [26] examines how AI and ML can be incorporated into e-learning systems, that is, in adaptive learning systems, to improve learning. An in-depth review of literature on 63 articles published in the period since 2010 shows the advantages and disadvantages of AI/ML in education. The adaptive learning algorithms that can customise the learning experience, streamline the learning journey, and enhance student interaction and achievement. Although issues such as data privacy and the complexity of the system exist, potential of AI/ML, in terms of changing the education system to one in which students learn individually, is clear.
Cepeda-Pacheco & Domingo [27] present an IoT-driven and DL recommendation system to improve tourist experience in smart cities. The system considers different inputs of user (travel details, personal information, up-to-date data of IoT devices (e.g., location, weather), and recommends appropriate tourist activities. The system, based on a multi-label DL classifier, provides a personalized recommendation both in process of pre-travel planning and in real-time provision of activity recommendations, unlike more traditional models such as decision trees and k-nearest neighbor classifiers, which degrade in performance measures. Sivamayil et al.,[28] present the uses of Reinforcement Learning (RL) to different fields, such as marketing, robotics, games, automated vehicles, natural language processing, IoT security, recommendation systems, finance and energy management. Bringing energy management point, review points out that RL can be used to optimize use of energy in smart buildings, hybrid vehicles, smart grids, and renewable energy systems. The constraints of traditional rule-based systems are surmounted because RW is flexible and effective to secure energy resources management and facilitating energy sustainability in other sectors.
2.5. Problem Statement
IoT has posed some serious security threats, especially in resource-constrained devices, which are limited by processing power, memory, and energy. Conventional security measures are unable to respond to the special needs of the IoT setting, which creates a necessity of lightweight cryptographic methods and new security models [19].
Due to increasing complexity of cyberattacks on IoT networks, the need to create effective IDS and AD models that can be used within these limitations is on the rise. Also, there is a possibility of integrating ML and blockchain technologies that would improve the security of IoT systems, and consumption of resources would be minimal [25].
This is necessitated by the need to have a thorough assessment of different security measures with the aim of striking a balance between performance, memory usage, energy consumption, and robustness to deal with the vulnerability of IoT devices and establish a safe communication in an environment that is gradually becoming interconnected.
3. Proposed Methodology
AD and security protocols suggestions for IoT devices. The procedure will start with the data gathering of smart home IoT equipment with a concern for the detection of normal and abnormal behavior. This data is then preprocessed, including activities such as data cleaning, missing value treatment, outlier treatment, normalization and balancing classes using SMOTE to deal with class imbalances. After preprocessing, information is sent to the security protocol recommendation system that oversees resources of the devices, identifies anomaly, and sets the correct security protocols based on a pre-existing database. The feedback loop imparts a constant adaptation of system on observed anomalies and availability of resources. Random Forest is used as classification step in which AD is done, and the behaviors are classified as either a Normal (0) or an Anomaly (1) is shown in Figure 1.
3.1. Data Collection
To collect data used Smart LED Light Dataset of Kaggle, since it contains normal and anomalous data of IoT devices in a smart home environment [29]. The dataset consists of many features that are network traffic, power usage, and device status (on/off) which are defined with normal (0) and anomalous (1). To cover all aspects of device behavior, it also gathered data about environmental variables, including device response time and resource consumption . Data can be analyzed with strong AD, and SMOTE can be used to balance the data to account for class imbalance between normal and anomalous behaviors.
3.2. Data Preprocessing
Preprocessing is the process of taking raw data and turning it into content that is useful for analysis and then, ultimately, machine learning. Preprocessing, in this case, refers to a series of steps that you take in data transformation process as follows: (1) Data cleaning - which is treating of any missing data, through imputation. (2) Outlier detection - This involves identifying any extreme data point and removing it, because it can affect performance. (3) Scaling and normalizing of features. This is typically done to ensure that continuous features such as power consumption, network traffic and time are on the same scale, and will subsequently improve performance. (4) In the case of class imbalances, this can be handled through class balancing methods or ideally SMOTE to ensure a fair model training process. The above steps will generate a cleaner and much more consistent dataset, you would expect, creates a better performing machine learning process.
3.2.1. Data Cleaning
The discovery and solving of problems in data contribute to its validity and internal consistency. This involves the treatment of missing values, where they are imputed by means, median or mode or records with missing values can be eliminated. The outlier detection is done with help of such methods as Z-scores or IQR to eliminate the extreme values that may distort the analysis. Also, data consistency maintains consistency in formats, including standardization of date-time values and category labels. To enhance the quality of dataset, it is important to perform proper data cleaning and, as a result, come up with more reliable and accurate ML.
3.2.2. Handling Missing Data
The process of treating missing data consists of locating and treating missing values in data to make the data complete. Imputation is one method in which missing values are substituted with statistical values, such as mean, median or mode of available values. Indicatively, when a feature X has missing values, then imputation can be performed as in Eq. (1)
where Xi is known values of feature X and n is number of known values. In median imputation missing score is assumed to be median M of observed scores:
3.2.3. Outlier Detection
Outlier detection is process of recognizing and eliminating extreme values that are not close to rest of data, because these may distort statistical analysis. A popular approach to identify outliers is Z score, which is number of standard deviation (SD). The value of a Z score above a threshold (e.g., |Z| > 3 ) therefore indicates that data point is an outlier. The point xi is obtained as in Eq. (2)
which xi is data point, μ and σ are mean and SD of feature. The method is Interquartile Range (IQR) method used to detect outliers and is referred to by range between first quartile and third quartile Q1 and Q3.
3.2.4. Normalization and Scaling
These are fundamental methods of data preprocessing to be able to compare the features that belong to different ranges or units to enhance the performance of ML. Scaling of features is done by feature scaling which in many cases employs MinMax scaling and normalizes values to range [0, 1] in Eq. (3)
where X is original value, Xminand Xmax are minimum and maximum possible values of feature. An alternative is Z -score standardization, by making data centered around mean and dividing data set by SD so that feature has a mean of zero and a SD of 1 is shown is Eq. (4)
which, μ is mean value and σ is SD of feature.
3.2.5. Class Balancing (SMOTE)
SMOTE is a technique applied to resolve the problem of class imbalance in data, when minority class (indicating anomaly, denoted 1) is underrepresented. SMOTE is based on creating artificial samples of minority groups instead of copying existing ones. The technique generates artificial instances by selecting an instance of a minority class, selecting its immediate neighbors and synthesizing new instances along line segments between selected instance and its neighbors. The synthetic sample Xˆ is computed by following formula in Eq. (5)
where, Xchosen is a randomly chosen example of the minority type, Xneighbor is among k nearest neighbors of Xchosen , The value, λ is random in 0 to 1 and determines distance along line segment between Xchosen and Xneighbor to which new sample will be generated.
Xˆ = Xchosen + λ ⋅ (Xneighbor − Xchosen )
3.3. Security Protocol Recommendation System
The Security Protocol Recommendation System (SPRS) is meant to facilitate changes in devices trust assessment based upon resources available real time as well as observed behavior of the device. This is important for establishing a compromise between security, reliability, device behavior and resource constraints (i.e. IoT devices under attack or low battery) , and scalability across thousands of IoT devices. The Security Protocol Recommendation system consists of two building blocks (components): the Security Protocols Database and the Security Protocol Recommendations Logic.
3.3.1. Security Protocols Database
The Security Protocols Database includes protocols that help secure IoT devices while meeting attributes for resource consumption and security strength. Security Protocols Database has a recommendation system that suggests an optimal security protocol based upon the state and behavior of the IoT device.
Listing Security Protocols: The database contains multiple protocols in terms of:
Security Strength: The gravitating seism uses AES-128 (low security) and AES-256 (high security) and ECC (medium security) and each of the protocols provides varying levels of security.
Resource Consumption: Resource consumption for calculating another attribute or dimension for classification is also important in terms of CPU power, memory used, battery used, or bandwidth used.
Assigning Protocol Parameters: Key parameters characterize each protocol in the database:
Encryption Strength: The strength of a particular protocol is indicated by strength - either through minimal key size or encryption mode.
Resource Usage: Resources can be either CPU cycles, memory or both to perform the encryption they are computer resources.
Battery and Network Overhead: Battery life and network overheads are very important in IOT, so it needs to be battery related or network condition that can strain limited memory.
3.3.2. Security Protocol Recommendation Logic
Security Protocol Recommendation Logic takes the Security Protocols Database to suggest the most appropriate security protocol depending on the available resources of the device and its current behavioral patterns. This guarantees dynamic adjustment of security measures to achieve balance between security and resource consumption in IoT devices.
Monitor Device Resources
Monitor important resources such as CPU usage, memory usage, battery, and network usage constantly. This assists in determining whether there are sufficient resources in the device to support security protocols with high resources or whether lightweight ones are required.
Detect Anomalies
Combine AD to detect possible security threats (e.g. unauthorized access or abnormal data flows) and unexpected resource consumption (signifying attacks such as DoS or DDoS). In the case of anomalies, prefer more secure measures, despite the fact that the device has few resources.
Feedback Loop
The positive loop enhances the system with time. Once every security measure is taken, performance feedback (e.g., power consumption, response time) and security feedback (e.g., anomaly mitigation success) is gathered by the system. This feedback allows the system to get the recommendations more precise and efficient so that a better and more efficient set of protocols is selected later.
3.4. Classification using Random Forest
The classification algorithm works of the Random Forest algorithm. It starts with dataset, and multiple subsets are generated based on dataset in a process known as bootstrapping, in which samples are selected randomly and with replacement. An individual decision tree is then trained using each subset. These trees learn varied patterns and associations within information and each tree generate its own output of classification, like Result-1, Result-2, etc., Result-n. Lastly, majority voting is used to combine all trees’ outputs where end prediction is one majority of trees are predicting. The end product defines whether source is Normal (0) or Anomaly (1) guaranteeing a sound and correct classification as shown in Figure 2.
3.4.1. Dataset (Input)
The data set consists of tuples of feature vectors and their corresponding labels. A feature vector xi has measurements or attributes describing data points, such as sensor readings, CPU usage, or network traffic. The label yi information is whether the data point is Normal (0) or Anomaly (1). The labelled data serves as training data for the learning model so that it can then classify new data points is in Eq. (6)
where xi are ith feature values, and yi is label associated with given data. It is taken as either zero or one, where 0 means "Normal" and 1 means "Anomaly".
D = {(x1,y1),(x2,y2),…,(xn,yn)}
3.4.2. Bootstrapping
Bootstrapping is a resampling method that involves the formation of several subsets of the initial data by chance. This method is useful in preventing overfitting and better generalization, because it is possible to train several models (e.g., decision trees in Random Forest) on slightly dissimilar versions of the dataset. Mathematically, bootstrapping creates a simulation of n bootstrapped subsets D1,D2,…,Dn of original dataset D with each subset Di consisting of m randomized samples (selection with replacement). The likelihood of sampling a given sample ( xi,yi) with one bootstrapped subset is , and the likelihood of a sample not being sampled is . So, the chance to be selected by at least one sample in m selection is in Eq. (7)
These bootstrapped subsets are then utilized to train separate decision trees, which are required to be diverse so as to enhance strength.
3.4.3. Decision Tree-1, Decision Tree-2, ..., Decision Tree-n
Each bootstrapped set Di is trained to create a decision tree by recursively splitting data using value of features to maximize information gain or minimize impurity. The decision tree construction process entails selection of optimal features to divide data at each node until leaf nodes are reached and ultimate prediction of classes is offered. The Gini Index is one such measure of impurity, which is computed as in Eq. (8)
where, pk is likelihood of class k on sample Di, C is number of classes. This recursive procedure of partitioning around minimization of Gini impurity produces decision trees and prediction is based on proportion of classes of leaf nodes.
3.4.4. Result-1, Result-2, ..., Result-n
Every tree in ensemble gives an outcome of classification depending on input features. With an input feature vector x, each decision tree Ti produces a prediction of a class, Ri with output potentially being 0 (Normal) or 1 (Anomaly), based on way data is partitioned in that one tree. The outcome of each of decision trees would be mathematically as shown in Eq. (9)
where, Tiis ith decision tree in ensemble, x is input feature vector, Riis expected output of ith decision tree (0 or 1 ). The aggregate prediction output in step two is then implemented using output of each tree.
Ri = Ti(x)
3.4.5. Majority Voting for Class Prediction
After all the branches of the decision tree provide a classification output, final decision is taken through majority vote whereby the most commonly used class (Normal or Anomaly) across all the decision trees is selected. The majority vote is given by adding the number of times the individual trees predict a particular class (0 or 1) and the class with the highest sum of the individual trees is chosen as the final forecast. The obtained scholar y 0 is mathematically obtained as in Eq. (10)
where, I(Ri = c) is an indicator, 1 when guess, Ri fits, c, and 0 when it does not, n is number of decision trees and Ri is a forecast of ith decision tree.
3.4.6. Final Output
Random Forest outcome is class prediction that is a majority vote of all the trees in ensemble. The resulting combination of all the trees is used to select the category where most of the votes are cast as the final prediction. The overall prediction is 0, and this behaviour is called normal when the majority of the trees vote class 0. But when the majority of the trees cast a class 1 vote which is an Anomaly-type behavior then the prediction is 1. This kind of grouping is what makes the prediction high and in line with the data and it avoids overfitting and enhances the generalization ability.
4. Results and Discussion
The proposed security framework operates and assesses its effectiveness in the optimization of security of IoT devices. The framework applies real-time AD and adaptive security protocols recommendations, which assist in mitigating the issue of resource-limited IoT devices. Accuracy, precision, recall, and F1 score measure the ability very well to distinguish between normal and anomalous behaviour. The confusion matrix, precision-recall curve, and ROC curve show that false positives (FP) and negatives (FN) are efficiently handled by the framework; thus, proving that it is able to strike a balance between security and resource consumption.
Computational Resources: The experiments for this research were conducted on a DESKTOP-ND1MRJE system equipped with a 12th Gen Intel(R) Core(TM) i5-12400 processor (2.50 GHz) and 8 GB of RAM (7.75 GB usable). The computational environment ran Python 3.12.11 with essential libraries such as pandas (2.3.1), numpy (2.2.6), matplotlib (3.10.0), seaborn (0.13.2), scikit-learn (1.6.1), and imbalanced-learn (0.13.0). The system uses a 64-bit operating system with an x64-based processor, and no pen or touch input is available for the display. This configuration provided sufficient resources to handle the computational demands of the machine learning models, ensuring efficient processing and training of the anomaly detection framework.
The calibration curve (or reliability diagram) of a Random Forest model, where predicted probabilities are compared with the actual results. The x-axis is forecasted probability (between 0 and 1) whereas y-axis depicts actual probability which shows actual fraction of true positives (TP) per bin of predicted probability. An ideally fitted model would have zeroes on diagonal line, which means that calculated probability would be same as the actual probability (e.g., when the probability is predicted to be 0.8, the probability should also be 0.8). In this curve, it observes that true probability in Random Forest model is high when predicted probability is high, and it indicates that is quite well-calibrated, though it can be improved in certain areas is depicted in Figure 3.
Confusion matrix of classification models contains following performance results: 20,989 true negatives (TN), where normal instances are correctly predicted as normal; 21,007 TP, where anomalies are correctly predicted as anomalies; 543 FP, where normal instances are incorrectly predicted as anomalies; and 525 FN, where anomalies are incorrectly predicted as normal. These findings suggest that work on whole, and many correct classifications (both normal and anomalous) will be made. It can still be improved, whereby FP and false negative values indicate that there are some misclassifications, especially between normal and anomalous cases is shown in Figure 4.
FNR (percentage of anomalies that were falsely classified as normal) is 0.0244 which means that 2.44% of anomalies were falsely classified. FPR that is used as ratio of number of normal cases that are wrongfully predicted by anomaly is somewhat more at 0.0252, indicating that 2.52 percent of normal cases are falsely classified. Both of these values are comparatively small which implies that it does well, however, FPR is somewhat higher than FNR which means that could be a little bit more susceptible to FP than to FN is shown in Figure 5.
Performance measures of classification model indicating Accuracy, Precision, Recall and F1 Score measures in Figure 6. Accuracy is 0.9752 which means that 97.52 percent of predictions are accurate. Precision = 0.9748, indicating that 97.48 percent of predicted anomalies are TP. The recall is 0.9756 which implies that it can detect 97.56 percent of actual anomalies. The F1 Score, which is weighted mean of precision and recall, is at 0.9752, indicating a good performance in both FP reduction and detection of anomalies. These measures show that is very precise and efficient in separating normal and abnormal behavior
To show trade-off between precision and recall of a classification model at varying thresholds. Precision is also high in curve with a value of close to 1 at low recall values, which shows that when predicts anomalies, it is very accurate. But with a rise in recall, precision also reduces marginally and this indicates it begins to predict more FP in an attempt to predict all anomalies. The score of average precision (AP) is 0.9967, which represents a wonderful general performance. A large value of AP indicates that the model has a good performance at all levels of recall, and its ability to detect anomalies is shown in Figure 7.
The classification model comparing True Positive Rate (TPR) with False Positive Rate (FPR) at different threshold settings is shown in Figure 8. The curve reveals that as the FPR rises, TPR rises sharply as well, indicating that it is discriminating against the true anomaly well hence maintaining the FP at a low rate. The AUC (Area Under the Curve) value of 0.9965 implies that it has very high discrimination power and it is highly likely to differentiate between normal and anomalous cases. The AUC is high and near 1, then it is a well-calibrated model with a high effectiveness in classification of data.
The performance of different anomaly detection models, which include k -Nearest Neighbors (k -NN), Isolation Forest, Support Vector Machine (SVM) and the proposed Random Forest approach. Random Forest methodology performs better in all the main evaluation measures, accuracy (97.52%), precision (97.48%), recall (97.56%), and F1-score (97.52) and it gives the highest AUC (0.9965). Compared to it, SVM has an accuracy of 95, and less precision and recall than the proposed approach. Isolation Forest has 94% accuracy, but weaker recall (91.0), and F1-score (92.0). k-NN is the worst at getting 92.5% accuracy, and has lower precision, recall, and F1. Random Forest is the best option in this study since it performs better in the detection of anomalies and class imbalances is shown in Table 1.
5. Conclusion and Future Work
The suggested work is able to combine AD with a system that can recommend a system of adaptive security protocols to fit resource-constrained IoT devices. It provides a high level of efficacy in detecting normal and anomalous behaviors by pre-processing data through cleaning, scaling, and imbalanced data with SMOTE, and then classifying data with the Random Forest algorithm. The feedback-based recommendation system actively modifies security measures depending on current resource availability on the device, achieving a tradeoff between providing high protection or wasting available resources. This approach creates some incentive to address weaknesses of the stand-alone static or consumptive cryptography techniques and secures the IoT ecosystems without a performance tradeoff. The findings indicate that the model is well-performing as it has an accuracy of 97.52 %, a precision of 97.48 %, and a recall of 97.56 %, meaning that it can reduce the number of FP and FN. These measures affirm that the framework is suitable when it comes to real-time detection of anomalies in IoT and security adaption. Nevertheless, it has room to be improved, especially the FPR, and scalability in large-scale IoT solutions. In the future, more complex patterns of anomaly, real-time processing of streams to detect them faster, and application of blockchain-based trust models can be integrated into work to further strengthen the protocol selection and enhance transparency in the provision of IoT security management.
Author Contributions
[Author to provide the contribution statement.].
Data Availability Statement
References
- Chataut, R.; Phoummalayvane, A.; Akl, R. Unleashing the Power of IoT: A Comprehensive Review of IoT Applications and Future Prospects in Healthcare, Agriculture, Smart Homes, Smart Cities, and Industry 4.0. Sensors 2023, 23, 7194. [Google Scholar] [CrossRef]
- Qiu, Y.; et al. Mobile Edge Computing in Space-Air-Ground Integrated Networks: Architectures, Key Technologies and Challenges. J. Sens. Actuator Netw. 2022, 11, 57. [Google Scholar] [CrossRef]
- Arent, D. J.; et al. Challenges and opportunities in decarbonizing the U.S. energy system. Renew. Sustain. Energy Rev. 2022, 169, 112939. [Google Scholar] [CrossRef]
- Di Nocera, F.; Tempestini, G. Getting Rid of the Usability/Security Trade-Off: A Behavioral Approach. J. Cybersecur. Priv. 2022, 2, 245–256. [Google Scholar] [CrossRef]
- Khashan, O. A.; Khafajah, N. M. Efficient hybrid centralized and blockchain-based authentication architecture for heterogeneous IoT systems. J. King Saud Univ.-Comput. Inf. Sci. 2023, 35, 726–739. [Google Scholar] [CrossRef]
- Paolone, G.; Iachetti, D.; Paesani, R.; Pilotti, F.; Marinelli, M.; Di Felice, P. A Holistic Overview of the Internet of Things Ecosystem. IoT 2022, 3, 398–434. [Google Scholar] [CrossRef]
- Tin, D.; Hata, R.; Granholm, F.; Ciottone, R. G.; Staynings, R.; Ciottone, G. R. Cyberthreats: A primer for healthcare professionals. Am. J. Emerg. Med. 2023, 68, 179–185. [Google Scholar] [CrossRef]
- Aslan, Ö.; Aktuğ, S. S.; Ozkan-Okay, M.; Yilmaz, A. A.; Akin, E. A Comprehensive Review of Cyber Security Vulnerabilities, Threats, Attacks, and Solutions. Electronics 2023, 12, 1333. [Google Scholar] [CrossRef]
- Altulaihan, E.; Almaiah, M. A.; Aljughaiman, A. Anomaly Detection IDS for Detecting DoS Attacks in IoT Networks Based on Machine Learning Algorithms. Sensors 2024, 24, 713. [Google Scholar] [CrossRef]
- Saleem, J.; Raza, U.; Hammoudeh, M.; Holderbaum, W. Machine Learning-Enhanced Attribute-Based Authentication for Secure IoT Access Control. Sensors 2025, 25, 2779. [Google Scholar] [CrossRef]
- Uddin, R.; Koo, I. Real-Time Remote Patient Monitoring: A Review of Biosensors Integrated with Multi-Hop IoT Systems via Cloud Connectivity. Appl. Sci. 2024, 14, 1876. [Google Scholar] [CrossRef]
- Nkenyereye, L.; Thakare, A.; Khataniar, P.; Imandi, R.; B N, P. K. Lightweight Authentication Protocol for Smart Grids: An Energy-Efficient Authentication Scheme for Resource-Limited Smart Meters. Mathematics 2025, 13, 580. [Google Scholar] [CrossRef]
- Radhakrishnan, I.; Jadon, S.; Honnavalli, P. B. Efficiency and Security Evaluation of Lightweight Cryptographic Algorithms for Resource-Constrained IoT Devices. Sensors 2024, 24, 4008. [Google Scholar] [CrossRef]
- Alwaisi, Z.; Kumar, T.; Harjula, E.; Soderi, S. Securing constrained IoT systems: A lightweight machine learning approach for anomaly detection and prevention. Internet Things 2024, 28, 101398. [Google Scholar] [CrossRef]
- Tanksale, V. Efficient Elliptic Curve Diffie–Hellman Key Exchange for Resource-Constrained IoT Devices. Electronics 2024, 13, 3631. [Google Scholar] [CrossRef]
- Hegde, P.; Maddikunta, P. K. R. Amalgamation of Blockchain with resource-constrained IoT devices for healthcare applications – State of art, challenges and future directions. Int. J. Cogn. Comput. Eng. 2023, 4, 220–239. [Google Scholar] [CrossRef]
- Bhavsar, M.; Roy, K.; Kelly, J.; Olusola, O. Anomaly-based intrusion detection system for IoT application. Discov. Internet Things 2023, 3, 5. [Google Scholar] [CrossRef]
- Antonius, F.; et al. Unleashing the power of Bat optimized CNN-BiLSTM model for advanced network anomaly detection: Enhancing security and performance in IoT environments. Alex. Eng. J. 2023, 84, 333–342. [Google Scholar] [CrossRef]
- Rafique, S. H.; Abdallah, A.; Musa, N. S.; Murugan, T. Machine Learning and Deep Learning Techniques for Internet of Things Network Anomaly Detection—Current Research Trends. Sensors 1968, 24, 1968. [Google Scholar] [CrossRef]
- Zohourian, A.; Dadkhah, S.; Molyneaux, H.; Neto, E. C. P.; Ghorbani, A. A. IoT-PRIDS: Leveraging packet representations for intrusion detection in IoT networks. Comput. Secur. 2024, 146, 104034. [Google Scholar] [CrossRef]
- Ismail, S.; Nouman, M.; Dawoud, D. W.; Reza, H. Towards a lightweight security framework using blockchain and machine learning. Blockchain Res. Appl. 2024, 5, 100174. [Google Scholar] [CrossRef]
- Javed, A.; Ehtsham, A.; Jawad, M.; Awais, M. N.; Qureshi, A.-H.; Larijani, H. Implementation of Lightweight Machine Learning-Based Intrusion Detection System on IoT Devices of Smart Homes. Future Internet 2024, 16, 200. [Google Scholar] [CrossRef]
- Sadhwani, S.; Manibalan, B.; Muthalagu, R.; Pawar, P. A Lightweight Model for DDoS Attack Detection Using Machine Learning Techniques. Appl. Sci. 2023, 13, 9937. [Google Scholar] [CrossRef]
- Ankita; Rani, S.; Singh, A.; Elkamchouchi, D. H.; Noya, I. D. Lightweight Hybrid Deep Learning Architecture and Model for Security in IIOT. Appl. Sci. 2022, 12, 6442. [Google Scholar] [CrossRef]
- Ferreira, L.; Silva, D. C.; Itzazelaia, M. U. Recommender Systems in Cybersecurity. Knowl. Inf. Syst. 2023, 65, 5523–5559. [Google Scholar] [CrossRef]
- Gligorea, I.; Cioca, M.; Oancea, R.; Gorski, A.-T.; Gorski, H.; Tudorache, P. Adaptive Learning Using Artificial Intelligence in e-Learning: A Literature Review. Educ. Sci. 2023, 13, 1216. [Google Scholar] [CrossRef]
- Cepeda-Pacheco, J. C.; Domingo, M. C. Deep learning and Internet of Things for tourist attraction recommendations in smart cities. Neural Comput Applic 2022, 34, 7691–7709. [Google Scholar] [CrossRef]
- Sivamayil, K.; Rajasekar, E.; Aljafari, B.; Nikolovski, S.; Vairavasundaram, S.; Vairavasundaram, I. A Systematic Study on Reinforcement Learning Based Applications. Energies 2023, 16, 1512. [Google Scholar] [CrossRef]
- MinisterJohn. Detecting Anomalies in Smart Home IoT Devices. Kaggle, 2024. Available online: https://www.kaggle.com/datasets/ministerjohn/detecting-anomalies-in-smart-home-iot-devices (accessed on Oct. 10 2025).
Figure 1.
Overall Proposed Framework.

Figure 2.
Random Forest Algorithm for AD.

Figure 3.
Calibration Curve.

Figure 4.
Confusion Matrix.

Figure 5.
FPR vs FNR.

Figure 6.
Performance Metrics.

Figure 7.
Precision-Recall Curve.

Figure 8.
ROC Curve.

Table 1.
Comparison with existing Method.
| Method | Accuracy | Precision | Recall | F1-Score | AUC |
| k-Nearest Neighbors (k-NN) | 92.5% | 90.0% | 90.0% | 90.0% | 0.92 |
| Isolation Forest | 94.0% | 93.5% | 91.0% | 92.0% | 0.93 |
| Support Vector Machine (SVM) | 95.0% | 94.0% | 92.0% | 93.0% | 0.94 |
| Random Forest (Proposed) | 97.52% | 97.48% | 97.56% | 97.52% | 0.9965 |
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. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.