Preprint
Article

This version is not peer-reviewed.

Advanced Deep Learning Approach for Smart Home Appliance Identification Using Recurrent Neural Networks with LSTM

A peer-reviewed version of this preprint was published in:
IoT 2024, 5(4), 835-851. https://doi.org/10.3390/iot5040038

Submitted:

12 October 2024

Posted:

14 October 2024

You are already at the latest version

Abstract
This study presents the development of a Recurrent Neural Network (RNN) model for classifying smart home device data. Utilizing a dataset sourced from Kaggle, the study explored the processes of data gathering, loading, normalization, and model construction. The RNN, equipped with Long Short-Term Memory (LSTM), was trained and evaluated, demonstrating significant improvements in training and validation accuracy over 10 epochs, culminating in a test accuracy of 83.25%, and only 35.4% loss. The evaluation of the model on the test set provides a test accuracy result, accompanied by an in-depth analysis of ROC curves and Area Under the Curve (AUC) scores for multi-class classification, along with a confusion matrix. The AUC score of 0.9896 indicates outstanding performance in accurately classifying IoT device categories. These findings indicate that the RNN with LSTM exhibits superior learning efficiency and generalization capabilities, making it more suitable for IoT device classification tasks. This article emphasizes the concept of IoT and reviews recent studies on the application of deep learning models across various IoT domains, including smart homes, industrial systems, and healthcare. Future research could focus on improving real-time processing capabilities, and scalability, and incorporating diverse IoT data types to enhance and broaden the model's practical applications.
Keywords: 
;  ;  ;  

1. Background

The Internet of Things (IoT) connects billions of Physical devices or individuals to the Internet and has become a highly popular and innovative technology over the past decade [1]. These physical devices are known as "things" or "objects" [2]. This intelligent methodology uses various protocols to exchange information through sensing devices. It expands the Internet, enabling the identification, location, and tracking of things. This approach allows for the development of small-scale devices with unique identification and computing capabilities, embedded with sensors and actuators, and connected through both wireless and wired sensor networks. The main characteristics of IoT include:
-
Perception: Sensors, Radio Frequency Identification (RFID), and barcodes are used to collect data about any object, anywhere. This also encompasses place and object identification and recognition of things.
-
Transmission: With the availability of networking and communication technologies, data can be accessed at any time. IoT ensures reliable transmission between machine-to-machine and mobile-to-machine connections.
-
Processing: Cloud computing facilitates the intelligent processing of IoT data. Service providers process millions or billions of data points using cloud computing. [3]
The IoT can be described as the "Internet of Everything" or the "Industrial Internet." It represents the latest technology that connects machines and devices. This field is crucial for the future of technology and has garnered significant attention from users and industries alike [2].By utilizing smart devices and the internet, IoT provides innovative solutions to various challenges faced by businesses, governments, and industries worldwide. IoT is increasingly becoming an integral part of our lives, evident in its widespread presence. Essentially, IoT integrates a vast array of smart systems, frameworks, intelligent devices, and sensors [4,5].
IoT technology has become essential in our lives, it cover a wide range of applications, from everyday consumer electronics to specialized industrial systems, such as fitness-tracking wristwatches, transport logistics, smart cars, manufacturing, and smart grids. Depending on their implementation, IoT devices can be used for real-time alerts, data archiving, trend analysis, and forecasting by utilizing related technologies like cloud services. Additionally, IoT has proven beneficial for both small- and large-scale networks, leading to a vast array of enabling hardware and software of varying complexities. This technology has influencing critical sectors like healthcare, smart water management, surveillance, biomedical applications, industrial processes, data center management, agriculture, body area networks (BANs), and more [1–3,6].
Due to the rapid growth in this field and the increasing number of diverse objects connected to various aspects of it daily, this paper focuses primarily on the identification of smart home objects, which is necessary to distinguish each object from others. The approach utilizes a Recurrent Neural Network (RNN) with Long Short-Term Memory (LSTM). Applying RNNs to smart home objects enhances the ability to transfer and apply the same model to other smart environments. These environments play a significant role in IoT applications, as they directly impact human safety, comfort, welfare, and security.
The rest of the paper is organized as follows. Section II, presents the previous work related to the use of deep learning algorithms in the identification of smart objects. Section III, discusses in details the steps and procedures of the development process of the RNN model for classifying of smart home objects. Section IV, reports an analysis of outcomes of th proposed model. Section V, provides the conclusion of the paper and possible recommendation for future work.

3. The Data and Method

This part presents the development process of the RNN model for classifying IoT device data. The key steps involved in constructing and assessing the proposed model are depicted in Figure 1. The diagram provides a visual representation of the main procedural stages, offering a highlight of the model development and evaluation process.

3.1. Data Preparing and Loading

This paper has uses available datasets on Kaggle.com. This dataset consists of smart home network comprising various IoT devices network traffic analysis data generated by other researchers.
The data used comes in form of two separate CSV files one of them is the test file and the other is train file as shown in Table I and Table II. To explore the content of each file, both files are loaded into Google Colab. Google Colab is a document that allows you to write, run, and share Python code within your browser. It is a version of the popular Jupyter Notebook within the Google suite of tools. Jupyter Notebooks (and therefore Google Colab) allow user to create a document containing executable code along with text, images, HTML, LaTeX, etc. which is then stored in your Google Drive and shareable to peers and colleagues for editing, commenting, and viewing.
The dataset contains 900 rows × 298 columns; rows represent the total number of instants, while columns represent attributes.
Table II. The array string of "device_category" in train:.
Table II. The array string of "device_category" in train:.
Title of device in array format Total number
array(['baby_monitor', 'lights', 'motion_sensor', 'security_camera',
'smoke_detector', 'socket', 'thermostat', 'TV', 'watch', 'water_sensor'], dtype=object)
10
Table I and II, shows an array of strings, containing names of different smart home devices. The array is one-dimensional, and has a total of 9 elements in the test file and total of 10 elements in the train file. Each element is a string representing the name of a device. So according to arrays shown in the above tables the element device 'water_sensor' is not included in iot_device_testnew.csv.
The only way to fix this problem is to combine the two sets in one new set and resplit them for the sake of the classification task; this way guarantees the existence of all ten elements in both sets after split.

3.2. Split the Data Set

There are at least three methods employed for computing the accuracy of a classifier. One approach involves splitting the training set. In another method called cross-validation, the training set is partitioned into mutually exclusive and equally-sized subsets. For each subset, the classifier is trained on the combination of all other subsets, and the average error rate across these subsets provides an estimate of the classifier's error rate. Leave-one-out validation is a specific instance of cross-validation where each test subset consists of a single instance. While computationally more intensive, this validation method is valuable when the most precise estimate of a classifier's error rate is necessary [14,15].
In this model the new dataset that created after combine the two main sets have been splits into training and test sets. In this case, 20% of the data will be used for testing and the remind data for training

3.3. Build and Evaluate the Model

This section will explore the details of using TensorFlow and Keras to construct a Recurrent Neural Network (RNN) featuring Long Short-Term Memory (LSTM) architecture.
The main step of constructing the model is reconfiguring the input features for both the training and test sets into a three-dimensional format. The prescribed format for LSTM networks is [samples, time steps, features], ensuring effective handling of the sequential structure inherent in the data.
The model defines the architecture of the RNN model consists of two LSTM layers with dropout for regularization and a Dense layer with softmax activation for the output layer in a multi-class classification scenario. Here’s an explanation of each steps of the model:
⮚
Initializes a sequential model, which is a linear stack of layers. This implies that each layer in the model has exactly one input tensor and one output tensor.
⮚
Use model. add (LSTM(200, return_sequences=True, input_shape=(X_train.shape[1], X_train.shape[2]))): Adds the first Long Short-Term Memory (LSTM) layer to the model. It consists of 200 units (or neurons) with the option return_sequences=True, which is suitable when stacking multiple LSTM layers. The input_shape parameter specifies the shape of the input data, where X_train.shape[1] represents the number of time steps, and X_train.shape[2] represents the number of features.
⮚
Introduces a Dropout layer with a dropout rate of 0.2. Dropout is a regularization technique that randomly sets a fraction of input units to zero during training, which helps prevent overfitting.
⮚
Adds a second LSTM layer with 200 units. This layer doesn't need return_sequences=True since it is the last LSTM layer in the stack.
⮚
Includes another Dropout layer with a dropout rate of 0.2 for regularization.
⮚
Adds a Dense (fully connected) layer with a number of units equal to the number of classes in the output. The activation function is set to 'softmax,' which is common for multi-class classification problems.
⮚
Configures the model for training. It specifies the optimizer as 'adam,' the loss function as 'categorical_crossentropy' (suitable for multi-class classification), and includes accuracy as the evaluation metric.
In summary, the provided model architecture comprises two Long Short-Term Memory (LSTM) layers with dropout regularization to prevent overfitting. The final layer is a Dense layer designed for multi-class classification, with the softmax activation function as shown in Figure 2. The model is compiled using the Adam optimizer and the categorical cross-entropy loss function, making it suitable for training on multi-class classification tasks. For more explanation, Figure 3 shows the structure of the RNN structure with 200 units in LSTM layers.
y 1 = s o f t max w x x 1 + w h h 0         ( 1_a ) y 2 = s o f t max w x x 2 + w h h 2         ( 1_b ) - - - y n = s o f t max w x x n + w h h n − 1         ( 1_n )

3.4. Train the Model:

The previously defined LSTM model trained using the fit method. Here’s a detail of each parameter:
⮚
X_train and y_train: Training data, where X_train is the input features, and y_train is the corresponding target labels.
⮚
epochs=10: The number of epochs specifies how many times the entire training dataset is passed forward and backward through the neural network. In this case, the model will undergo 10 epochs of training.
⮚
batch_size=32: The batch size determines the number of samples used in each iteration for updating the model weights. A batch size of 32 means that 32 samples from the training dataset will be used in each iteration.
⮚
validation_split=0.2: This parameter designates 20% of the training data as the validation set. The model's performance on this subset will be monitored during training, providing insights into its generalization capabilities.
⮚
verbose=2: This controls the verbosity of the training process during each epoch. A value of 2 means that training progress will be displayed per epoch, showing a progress bar for each epoch.
The output returns two values: test loss and test accuracy. Test loss measures how well the model's predictions match the actual values in the test dataset. Lower test loss indicates better performance. Test accuracy measures the percentage of correct predictions made by the model on the test dataset. Higher test accuracy indicates better performance. The training output is illustrated in Table III.
Table III. The training process output of the main model.
Table III. The training process output of the main model.
Epoch 1/10
38/38 - 5s - 135ms/step - accuracy: 0.4885 - loss: 1.7056 -
val_accuracy: 0.5888 - val_loss: 1.1190
Epoch 2/10
38/38 - 1s - 14ms/step - accuracy: 0.6776 - loss: 0.8666 -
val_accuracy: 0.7171 - val_loss: 0.7538
Epoch 3/10

38/38 - 1s - 22ms/step - accuracy: 0.7673 - loss: 0.5748 -
val_accuracy: 0.7566 - val_loss: 0.5595
Epoch 4/10
38/38 - 1s - 37ms/step - accuracy: 0.8141 - loss: 0.4504 -
val_accuracy: 0.7961 - val_loss: 0.4872
Epoch 5/10
38/38 - 1s - 37ms/step - accuracy: 0.8215 - loss: 0.3937 -
val_accuracy: 0.7895 - val_loss: 0.4293
Epoch 6/10
38/38 - 1s - 29ms/step - accuracy: 0.8380 - loss: 0.3656 -
val_accuracy: 0.8191 - val_loss: 0.3961
Epoch 7/10
38/38 - 1s - 16ms/step - accuracy: 0.8372 - loss: 0.3508 -
val_accuracy: 0.8289 - val_loss: 0.3778
Epoch 8/10
38/38 - 1s - 15ms/step - accuracy: 0.8512 - loss: 0.3222 -
val_accuracy: 0.8322 - val_loss: 0.3635
Epoch 9/10
38/38 - 1s - 17ms/step - accuracy: 0.8553 - loss: 0.3106 -
val_accuracy: 0.8355 - val_loss: 0.3478
Epoch 10/10
38/38 - 1s - 15ms/step - accuracy: 0.8586 - loss: 0.2900 –
val_accuracy: 0.8355 - val_loss: 0.3412
12/12 - 0s - 5ms/step - accuracy: 0.8316 - loss: 0.3540
Test Accuracy: 0.8316
12/12 [==============================] -1s
31ms/step

3.5. Evaluate the Model

After training a model, it's essential to assess its performance on unseen data to determine how well it generalizes. To evaluate the model's effectiveness, we present the ROC curve, the area under the curve (AUC), and the confusion matrix.

3.5.1. The ROC Curve and the Area under Curve AUC

The Receiver Operating Characteristic (ROC) curve, a two-dimensional metric for classification performance, is examined in this study. The focus is on the scalar measure known as the area under the ROC curve (AUC), which evaluates a specific aspect of performance [16].
The paper concludes that AUC effectively distinguishes the ten IOT device categories, it gets an output of micro-average ROC score = 0.9896. The ROC AUC score of 0.9896 indicates that the classifier has excellent overall performance in distinguishing between different classes. This means that the classifier can correctly classify a high proportion of both positive and negative examples across all classes.
In summary, a micro-average ROC AUC score of 0.9896 signifies a highly effective and discriminative model across various classes, but a more in-depth analysis is recommended for a nuanced interpretation and insights into specific class performance.
The following figure shows the plot of the ROC curves for a multi IoT devices classification problem.
The plot illustrated in Figure 4, provides a comprehensive visualization of the model's performance in a multi-IoT devices classification setting using ROC curves. It allows for the assessment of how well the model distinguishes between classes, with the micro-average offering an overall measure. The diversity of colors aids in distinguishing between individual class curves.
Figure 4. Plot the micro-average ROC curve.
Figure 4. Plot the micro-average ROC curve.
Preprints 121062 g004

3.5.2. The Confusion Matrix

A confusion matrix is a key tool in classification used to evaluate model performance. It provides a detailed breakdown of predictions by showing the counts of:
-
True Positives (TP): Correctly predicted positive cases.
-
True Negatives (TN): Correctly predicted negative cases.
-
False Positives (FP): Incorrectly predicted positives (Type I error).
-
False Negatives (FN): Incorrectly predicted negatives (Type II error). [15,17]
By visualizing these results, it helps identify class confusions and calculate important metrics such as accuracy, precision, recall, and F1-score, offering insights into the model’s effectiveness.
The figure below displays the confusion matrix for a multi-IoT device classification problem, where an RNN with an LSTM model was used.
Figure 5. The confusion matrix.
Figure 5. The confusion matrix.
Preprints 121062 g005
The confusion matrix in the above figure shows that the model has high accuracy, as most of the predictions are located on the diagonal. For example, the model correctly predicted 37 samples as security cameras (class 0). It incorrectly predicted 1 sample as a baby monitor (class 6) which was actually a security camera. Looking at another example, the model correctly predicted 38 samples as watches (class 5). It incorrectly predicted 2 samples as baby monitors (class 6), which were watches.

4. Results Analysis

This section aims to assess their methodologies, architectures, and results, this analysis seeks to provide insights into the relative strengths and weaknesses of the model and provide insights into its efficacy and reliability in real-world applications. The proposed method outlines a comprehensive methodology for developing and evaluating a deep learning model for IoT device classification. Here's a breakdown and analysis of the key components:
  • Methodology for Model Development and Evaluation:
The research presents a step-by-step approach for developing and evaluating a deep learning model specifically designed for IoT device classification. This suggests a structured and systematic process, which is crucial for reproducibility and reliability in research.
2.
Data Handling Process:
Addressing discrepancies between training and test sets is crucial for ensuring the robustness of the model. This indicates a thorough consideration of data preprocessing and validation techniques to mitigate potential biases or overfitting issues.
3.
Model Architecture:
The use of an LSTM-based RNN model is explained in detail, highlighting architectural choices and training parameters. LSTM (Long Short-Term Memory) networks are well-suited for sequence data, indicating that the model is tailored to handle temporal aspects inherent in IoT device data.
4.
Training Process and Performance:
The high accuracy achieved on the training set suggests that the model effectively learns from the training data. However, the challenges in generalizing to unseen data underscore the importance of robust evaluation metrics beyond training accuracy.
5.
Model Evaluation:
Evaluation on the test set includes metrics such as ROC curves and AUC scores for multi-class classification. The AUC score of 0.9896 signifies outstanding performance in classifying various IoT device categories, indicating the model's effectiveness in distinguishing between different classes.
6.
Contributions and Implications:
The research contributes a comprehensive guide for developing and evaluating deep learning models in IoT device classification scenarios. This suggests potential applications in various IoT domains, such as smart homes, industrial automation, and healthcare monitoring [15].

5. Conclusions

This paper presents a comprehensive methodology for the development and evaluation of a deep learning model tailored for IoT device classification. The data handling process addresses potential biases between training and test sets, ensuring a robust foundation for model training. The utilization of a Long Short-Term Memory (LSTM)-based Recurrent Neural Network (RNN) model is thoroughly explained, highlighting key architectural decisions and training parameters. During the training process, the model achieves high accuracy on the training set, indicating its ability to learn from the provided data. However, challenges arise in generalizing to unseen data, underscoring the importance of robust evaluation metrics. Model evaluation on the test set yields a test accuracy result and includes a detailed analysis of ROC curves and Area Under the Curve (AUC) scores for multi-class classification, as well as a confusion matrix. The obtained AUC score of 0.9896 signifies exceptional performance in classifying various IoT device categories.
The final results show that the proposed model emerged as the superior approach, offering stable learning without overfitting and demonstrating superior test accuracy. Its structured methodology and robust evaluation metrics position it as a reliable framework for IoT device classification tasks.
In summary, this article contributes a comprehensive guide for developing and evaluating deep learning models in IoT device classification scenarios. It underscores the importance of addressing data handling challenges, robust evaluation techniques, and further analysis for nuanced insights into model performance.
In conclusion, the Internet of Things (IoT) has transformed device connectivity, providing intelligent solutions across sectors like smart homes, healthcare, and industry. The application of deep learning models, particularly Recurrent Neural Networks (RNN) with Long Short-Term Memory (LSTM) architectures, has demonstrated strong effectiveness in classifying and differentiating IoT devices. This study lays the groundwork for further advancements in developing reliable IoT classification systems and driving innovation in IoT technologies.

References

  1. Juan Ruiz-Rosero 1,* ID, Gustavo Ramirez-Gonzalez 1 ID, Jennifer M. Williams 2 ID,Huaping Liu 2, Rahul Khanna 3 ID and Greeshma Pisharody .(2017).Internet of Things: A Scientometric Review. Symmetry,MDPI. [CrossRef]
  2. Aditi Rajesh Nimodiya1 and Shruti Sunil Ajankar. (2022). A Review on Internet of Things. International Journal of Advanced Research in Science, Communication and Technology (IJARSCT). [CrossRef]
  3. S. Dhiviya, S. Malathy, D. Rajesh Kumar. (2018). Internet of Things (IoT) Elements, Trends and Applications. Journal of Computational and Theoretical Nanoscience. [CrossRef]
  4. Alshaya, S.A. (2023). IoT Device Identification and Cybersecurity: Advancements, Challenges, and an LSTM-MLP Solution. Engineering, Technology & Applied Science Research. 13, 6 (Dec. 2023), 11992–12000. [CrossRef]
  5. Sachin Kumar1*, Prayag Tiwari2 and Mikhail Zymbler.(2019). Internet of Things is a revolutionary approach for future technology enhancement: a review.Joournal of big Data. [CrossRef]
  6. Alsulami, R., Alqarni, B., Alshomrani, R., Mashat, F. and Gazdar, T. (2023). IoT Protocol-Enabled IDS based on Machine Learning. Engineering, Technology & Applied Science Research. 13, 6 (Dec. 2023), 12373–12380. [CrossRef]
  7. Singla K, Bose J. (2018). IoT2Vec: Identification of Similar IoT Devices via Activity Footprints. International Conference on Advances in Computing, Communications and Informatics (ICACCI). [CrossRef]
  8. Yin F, Yang L, Ma J, Zhou Y, Wang Y, Dai J. (2021). Identifying IoT Devices Based on Spatial and Temporal Features from Network Traffic. Hindawi. Article ID 2713211. [CrossRef]
  9. Mainuddin M, Duan Z, Dong Y, Salman S, Taami T. (2022). IoT Device Identification Based on Network Traffic Characteristics. IEEE Global Communications Conference.
  10. Zahid H, Saleem Y, Hayat F, Khan F, Alroobaea R, Almansour F, Ahmad M, Ali I. (2022). A Framework for Identification and Classification of IoT Devices for Security Analysis in Heterogeneous Network. Hindawi, Wireless Communications and Mobile Computing. [CrossRef]
  11. Qiang Y, Kumar S, Marco Brocanelli, Zhu D. (2022). Tiny RNN Model with Certified Robustness for Text Classification. International Joint Conference on Neural Networks (IJCNN). [CrossRef]
  12. Jaidip Kotak and Yuval Elovici. (2020). IoT Device Identification Using Deep Learning. arXiv:2002.11686. [CrossRef]
  13. Swapna Thouti a, Nookala Venu b, Dhruva R. Rinku a, Amit Arora a, N. Rajeswaran. (2022). Investigation on identify the multiple issues in IoT devices using Convolutional Neural Network. ELSEVIER, Measurement Sensors Journal.
  14. B. Kotsiantis.(2007). Supervised Machine Learning: A Review of Classification Techniques. informatica. DOI: 31:249-268.
  15. Part of the cited section is written with aid of either ChatGPT or Google Colab.
  16. Marzban C. (2004).The ROC Curve and the Area under It as Performance Measures. American Meteorological Society (AMS). [CrossRef]
  17. Alenazi, M. and Mishra, S. (2024). Cyberatttack Detection and Classification in IIoT systems using XGBoost and Gaussian Naïve Bayes: A Comparative Study. Engineering, Technology & Applied Science Research. 14, 4 (Aug. 2024), 15074–15082. [CrossRef]
Figure 1. Procedural stages of the proposed model.
Figure 1. Procedural stages of the proposed model.
Preprints 121062 g001
Figure 2. Illustration of applying Softmax activation function.
Figure 2. Illustration of applying Softmax activation function.
Preprints 121062 g002
Figure 3. Illustration of the RNN structure with 200 units in LSTM layers.
Figure 3. Illustration of the RNN structure with 200 units in LSTM layers.
Preprints 121062 g003
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.
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.