Real-Time IoT Intrusion Detection Report
Real-Time IoT Intrusion Detection Report
By
K Amulya 21321A1209
B Deeksha 21321A1221
P Kaveri 21321A1240
AY 2024–25
Bhoj Reddy Engineering College for Women
Department of Information Technology
(Sponsored by Sangam Laxmibai Vidyapeet, Accredited by NAAC with A Grade, Approved by AICTE and Affiliated to JNTUH)
Recognized by UGC under section 2(f) of the UGC Act, 1956.
Vinaynagar, IS Sadan Crossroads, Saidabad, Hyderabad – 500 059, Telangana. [Link]
CERTIFICATE
This is to certify that the Mini Project entitled “Detection of Real Time Intrusions and
K Amulya 21321A1209
B Deeksha 21321A1221
P Kaveri 21321A1240
In partial fulfillment for award of the degree of Bachelor of Technology in Department of Information
Technology from Bhoj Reddy Engineering College for Women, Hyderabad affiliated to Jawaharlal
Nehru Technological University Hyderabad (JNTUH).
Sangam Laxmibai Vidyapeet is an educational society for promotion of education among girls and women.
It is established in 1952 and registered under the Telangana Societies Registration Act.
ACKNOWLEDGEMENT
It is our pleasure to express our whole hearted thanks to our internal guide Saleha Farha,
Assistant Professor, Department of Information Technology, for her extreme guidance and
support in completing this project successfully.
We are thankful to our project coordinator Tasneem Rahath, Assistant Professor,
Department of Information Technology, for her dynamic valuable guidance and constant
management.
We express thanks and gratitude to Dr C Murugamani, Professor & Head of the
Department, Information Technology, for his encouragement and guidance in carrying out
the mini project presentation.
We would also like to thank Dr J Madhavan, Professor & Principal of Bhoj Reddy
Engineering College for Women for encouragement in carrying out our mini project
successfully. We are also thankful to the staff members of Information Technology department,
my friends and to our parents who helped us in completing this project successfully.
By
K Amulya (21321A1208)
B Deeksha (21321A1221)
P Kaveri (21321A1240)
Index
Contents Page No
List of Tables i
List of Figures ii
Abstract iii
1. Introduction 1-5
1.1 Introduction of the Project 2-3
1.2 Purpose 3-4
1.3 Existing System 4
1.4 Proposed System 4-5
4. Design 14-30
4.1 Architecture 15
[Link] Database 16
[Link] Normalization 18
[Link] 31-49
5.1 Deep learning 32-33
5.2 Technologies 33-39
5.2.1 Frontend Interface 33-34
[Link] Flask 33
[Link] HTML, CSS, JavaScript 34
5.2.2 Python 34-35
5.2.3 Backend Data handling 35-36
[Link] NumPy 35
[Link] Pandas 36
[Link] Scikit- learn 36
[Link] TensorFlow 36
5.2.4 Utility & Support 37-38
[Link] Matplotlib 37
[Link] Label Encoder 37
[Link] Min Max Scaler 37
[Link] Adam Optimize 38
5.3 Code 39-49
[Link] 50-56
[Link] & Validation 57-61
[Link] 62-63
[Link] Scope 64-65
List of Tables
1 Test Cases 60
2 Test Validation 60
i
List of Figures
ii
ABSTRACT
1. Introduction
Modern IDS solutions increasingly utilize data mining techniques to enhance accuracy and
behavior modeling. This allows them to respond more effectively to sophisticated and evolving
cyber threats than traditional systems. Despite their evolution, existing IDSs still face notable
limitations, particularly in detecting novel or complex attacks. Issues such as low detection
accuracy, high false positive rates, and limited adaptability to new threat vectors remain prevalent
challenges in the cybersecurity landscape. With the exponential growth of the Internet of Things
(IoT), especially within Industrial Internet of Things (IIoT) environments, the security stakes have
become even higher. Industrial Control Systems (ICS), forming the backbone of critical
infrastructures, are now more vulnerable due to the increasing number of connected devices. This
surge in connectivity has expanded the attack surface, making it imperative to develop more robust
intrusion detection mechanisms. To address these concerns, the proposed project introduces an
advanced IDS framework based on deep-autoencoder-based LSTM models, specifically tailored
for IIoT-powered Industrial Internet of Cyber-Physical Systems (IICs).
This approach not only enhances detection capabilities but also significantly lowers the false
positive rate.
Furthermore, the system integrates an ensemble learning method to boost overall accuracy and
reliability, combining the strengths of multiple models for more comprehensive intrusion analysis.
By integrating cutting-edge deep learning methods and emphasizing real-time detection with
reduced false alerts, this project aims to provide a more effective, scalable, and secure IDS solution
for modern, dynamic, and high-risk network environments such as those driven by IoT and IIoT
infrastructures.
Another key objective is to integrate advanced deep learning techniques, including both
unsupervised and discriminative models, to effectively detect and classify cyber threats in cyber-
physical systems, particularly within IoT-driven Industrial Internet of Cyber-Physical Systems
(IICs). The system aims to handle complex network environments by improving the detection of
novel and sophisticated attack patterns that conventional method often misses.
It is to ensure the confidentiality, of sensitive user and system data during the training and testing
phases. By incorporating a GAN into the detection framework, the system is designed to achieve
high detection and true positive rates across multiple datasets and attack scenarios, while
maintaining a strong defense against a wide range of cybersecurity threats.
It includes ensuring real-time adaptability and scalability of the intrusion detection system in
highly dynamic IoT ecosystems. As network topologies, device behaviors, and threat vectors
evolve rapidly, the system must not only detect anomalies but also learn and adapt from ongoing
activity patterns without constant manual intervention. To this end, the proposed IDS aspires to
incorporate continuous learning mechanisms, edge-based deployment for low-latency inference,
and federated learning models that facilitate collaborative training across distributed environments
while preserving data privacy.
• We introduce a more diverse range of deep learning techniques and various generative
adversarial network (GAN) architectures (RBN, DBN, DBM, and DA). This broader range
of approaches might lead to improved detection performance and adaptability.
2. Related Work
2.1 Survey:
João Azevedo et al. conducted a comprehensive evaluation of several Convolutional Neural
Network (CNN) architectures—namely AlexNet, VGG, Inception, and ResNet—to assess their
performance in both static image classification and dynamic video recognition tasks. The models
were initially tested using the ImageNet dataset to determine their accuracy and error margins.
Following this, their ability to detect temporal patterns and classify human activities in video
streams was analyzed. Among the models, ResNet and Inception demonstrated superior accuracy,
each exceeding a 70% success rate. This study reinforces the feasibility of applying CNN-based
deep learning models to interpret and classify video data generated from sensor-fed environments,
such as surveillance or human activity monitoring systems.
Eric Gyamfi et al. focused on the growing vulnerabilities within the Internet of Things (IoT)
ecosystem, especially in the context of constrained devices. Their survey highlighted how the rapid
expansion of IoT applications increases the computational load and network traffic, while
simultaneously exposing these lightweight devices to heightened cybersecurity threats. As
traditional security mechanisms are often unsuitable for such environments, the authors reviewed
the applicability of Network Intrusion Detection Systems (NIDS) integrated with Mobile Edge
Computing (MEC) and machine learning techniques. Their work emphasizes the importance of
dataset availability, evaluation metrics, and real-time deployment models, culminating in the
proposal of a robust, MEC-supported NIDS framework tailored for secure IoT communication.
Abdullah Ayub Khan et al. introduced B-Drone, a novel framework for drone-based data
management that integrates fog computing with blockchain smart contracts, specifically
Hyperledger Fabric. This architecture ensures secure data transmission using SHA-256 hash
encryption and employs smart contracts to manage communication between drones and fog nodes.
Their work aims to enhance the traceability and security of UAV networks, particularly in
surveillance or logistics applications. However, the study also cautions that careless
dimensionality reduction could lead to data loss, emphasizing the need for dataset-specific tuning
during training and evaluation phases.
In another study, Mr. Amit Kr. Balyan et al. proposed a hybrid intrusion detection system that
combines Evolutionary Genetic Algorithms (EGA) and Particle Swarm Optimization (PSO) with
an enhanced Random Forest classifier. This two-phase approach first selects the most relevant
features using a multi-objective genetic function, thus reducing data dimensionality and
complexity. In the second phase, an improved Random Forest model eliminates non-contributing
features and utilizes ensemble decision trees to enhance classification performance. The model
addresses limitations of earlier techniques that suffered from imbalance and false detections due
to sparse training data.
Karan Gupta et al. discussed the dual-edged nature of connected healthcare devices. While these
technologies enable scalable and accessible medical services, they also introduce significant
cybersecurity risks, potentially threatening patient privacy and safety. Their work underscores the
need for secure architectural designs to protect sensitive health data transmitted across networks.
Further contributions by Abdullah Ayub Khan et al. addressed the growing communication
demands in UAV-assisted vehicle networks within smart cities. Their research proposed a
blockchain-powered lifecycle framework that enables secure and transparent communication
among distributed vehicle nodes. Despite its potential, the framework poses challenges in terms of
system complexity and processing overhead, which must be addressed for real-world
implementation.
In the healthcare domain, Khan et al. also proposed a blockchain-based architecture named BIoMT
(Blockchain-based Internet of Medical Things), tailored for managing sensitive patient data. The
architecture employs serverless networks, NuCypher-based re-encryption for data privacy, and
smart contracts for automation of device registration and ledger management. Though the system
provides enhanced security and traceability, it also introduces complexity in terms of
cryptographic overhead and blockchain governance, particularly in resource-constrained medical
environments.
Overall, the related literature highlights a strong trend toward hybrid architectures that integrate
machine learning, blockchain, and edge/fog computing to meet the demands of modern
applications in security, healthcare, and video processing. However, challenges around data
privacy, computational resource constraints, and system scalability remain critical areas for
continued research and innovation.
[Link] Analysis
Taking into account the comparative analysis stated in the previous section we could start specifying
the requirements that our website should achieve. As a basis, an article on all the different
requirements for software development was taken into account during this process. We divide the
requirements in 2 types: functional and non- functional requirements.
Functional requirements clearly explain what a system should do to meet its goals. They describe
how the system should take input, process it, and give the right output based on user and business
needs. These requirements guide the entire project—from planning to delivery—by showing what
features and functions the system must have.
They should be easy to understand, specific, and detailed so developers know exactly what to build
and testers know what to check. By defining how users and the system interact, functional
requirements help with design, planning, and keeping everything on track. In short, they reduce
confusion and help ensure the system works the way users expect.
• Registration
• Authentication
• Dataset Overview
• Traffic Monitoring
• Alerting
• Intrusion Classification
• Dataset Management
• System Scaling
• Usability
• Serviceability
• Data Integrity
• Capacity
• Manageability
• Recoverability
• Security
• Availability
Python: Python serves as the core programming language used throughout the project. Its simple
and readable syntax makes it an ideal choice for both beginners and experienced developers.
Python’s emphasis on code clarity and modularity significantly reduces the cost and complexity of
maintaining and scaling software applications. One of Python’s key strengths lies in its extensive
standard library and active community support, which offers a wide range of packages and
frameworks for various tasks, including data processing, visualization, and machine learning.
Furthermore, Python is a cross-platform language, and its interpreter, along with the majority of its
libraries, is freely available in both source and binary forms, making it highly accessible and cost-
effective for academic and industrial use.
Hardware Requirements
Operating System : Windows Only
Processor : i5 and above
Ram : 8gb and above
Hard Disk : 25 GB in local drive
Deployment Requirements
Dataset : KDDCUP99, NSL KDD ,UNSW-NB15
[Link]
4.1 Architecture:
Fig4.1.2.1SystemArchitecture
[Link] Database:
SQLite3 is a lightweight, file-based database used for storing input data, user logs, and
historical predictions in a structured format. It integrates easily with Python and Jupyter
Notebooks, making it ideal for data analysis and machine learning workflows. The database
supports fast and efficient data retrieval, enabling smooth access during model training and
testing phases. Its portability allows it to operate without the need for a dedicated server, making
it convenient for deployment across various environments.
[Link] Normalization
Normalization is a data preprocessing technique used to scale numerical input features to a
common range, typically between 0 and 1. This process ensures that no single feature dominates
the learning algorithm simply because of its scale. In many machine learning models—
especially those based on distance calculations, like k-NN, or gradient-based optimizations, like
neural networks—features with larger numeric values can unintentionally carry more weight,
skewing the model's understanding and leading to biased or inefficient learning. By normalizing
the data, each feature contributes equally to the learning process, improving the stability,
convergence speed, and overall performance of the model. This step also helps reduce the
impact of outliers and ensures that the model is not sensitive to the units or magnitude of the
raw data.
4.1.4 Modules:
Module is a part of a program. Programs are composed of one or more independently developed
modules. A module description provides detailed information abou t a module and its supported
components. The modules are:
• Dataset Collection
• Data Preprocessing
• Deep Learning Models
• Training and Testing
• Performance Metrics Analysis
• Real-Time Detection and Response
Dataset Collection:
Dataset collection serves as the foundation of an effective intrusion detection system. Utilizing
benchmark datasets such as NSL-KDD, KDDCup99, and UNSW-NB15 ensures that the system
is trained and tested on diverse and representative data. These datasets provide both labeled and
unlabeled records, enabling the models to learn patterns associated with various types of attacks
as well as normal activities.
Data Preprocessing:
Data preprocessing is essential to ensure that the input data is clean, consistent, and optimized
for machine learning. This phase involves normalizing and scaling the data to maintain
uniformity across features, which is vital for improving model performance. Feature extraction
techniques are employed to reduce redundancy by selecting the most relevant attributes, thereby
enhancing computational efficiency.
Algorithm:
Convolutional Neural Network:
Convolutional Neural Networks (CNNs) are a class of deep learning models widely recognized
for their ability to extract hierarchical features from input data through convolutional
operations. Although traditionally employed for image recognition tasks, CNNs have been
effectively adapted in this project for intrusion detection by learning spatial patterns and
relationships between features in network traffic data. The CNN model processes structured
inputs—such as protocol types, service requests, and flag statuses—by identifying local feature
combinations that may signify cyber threats. By automatically learning these representations,
CNNs contribute significantly to reducing false positives and increasing detection accuracy in
recognizing specific types of known attacks within IoT networks.
This is especially valuable because IoT devices generate vast amounts of data, often hiding
attack patterns within large volumes of network traffic. CNNs can efficiently process this data
in real time, learning hierarchical representations that help identify both known and unknown
threats, including Denial-of-Service (DoS) attacks, data injection, spoofing, botnets, and
malicious firmware updates.
The CNN architecture is designed to identify complex patterns in IoT traffic data and
distinguish between normal behavior and potential threats in real time. The main components
of such a CNN are:
Input Layer
The input layer is the entry point of the CNN model, where raw data is fed into the network. In
the context of IoT intrusion detection, this input is usually structured data derived from network
traffic. Common features include packet size, protocol type, source and destination IP
addresses, port numbers, time intervals between packets, and the type of network connection.
Pooling Layers
Pooling layers are used to downsample the feature maps generated by the convolutional layers.
They reduce the spatial size of the data while retaining the most important [Link] pooling
is the most common type, where the highest value in each small region of the feature map is
selected. For intrusion detection, max pooling ensures that the most significant feature
indicating malicious behavior (e.g., an unusual spike in requests) is preserved while less
relevant data is discarded.
Output Layer
The output layer is the final part of the CNN and is responsible for generating the prediction
result. This layer provides the final decision—identifying the type of network behavior based
on the patterns learned by the hidden layers. For real-time systems, this output can trigger alerts
or automated defenses.
IoT devices generate data in a time-ordered sequence, such as packet logs, command signals,
sensor readings, and communication timestamps. Unlike standard machine learning models,
RNNs can remember previous inputs using their internal memory, making them ideal for
detecting patterns that unfold over [Link] are effective in identifying:
• Gradual increase in data flow (e.g., slow DoS attacks)
• Periodic malicious access attempts (e.g., brute-force login)
• Sudden deviation from normal behavior
• Complex, multi-step attacks
Recurrent Neural Networks (RNNs) are well-suited for detecting intrusions in IoT
environments due to their ability to process and learn from time-sequential data. Their
architecture mimics how events occur in real time, making them ideal for analyzing network
traffic that unfolds over multiple time steps.
The input layer receives sequences of time-ordered features such as packet size, IP addresses,
ports, protocols, timestamps, and sensor outputs. Unlike traditional models that treat inputs as
isolated points, this layer structures the data chronologically, allowing the RNN to analyze the
behavioral flow of network activity as it naturally occurs.
RNN’s hidden layers contain recurrent units that maintain memory across time steps, enabling
the model to recognize evolving patterns such as gradual traffic anomalies or multi-stage
attacks. Advanced forms like LSTM and GRU (Gated Recurrent Unit) enhance this capability
by managing what information to retain or forget, making them effective at identifying long-
term dependencies and suppressing irrelevant [Link] handle non-linear and complex attack
patterns, activation functions like Tanh, ReLU, and Sigmoid are applied within the network.
These functions help the model learn from nuanced variations in data, which is critical for
detecting stealthy or rare attacks that don't follow simple [Link] output layer interprets the
learned sequence patterns and classifies network behavior into categories such as normal, DoS,
probe, or malware attack. Depending on the setup, it uses Sigmoid (for binary classification) or
Softmax (for multi-class classification) to produce predictions. The results from this layer can
trigger automatic security responses or alert systems.
By feeding the CNN with structured, image-like input, we empower the model to simulate how
network behaviors unfold, thereby offering a more accurate understanding of real-time events.
This is crucial in cybersecurity because attack behaviors are rarely linear or straightforward.
ReLU ensures that the model focuses only on impactful signals, ignoring noise or irrelevant
fluctuations in the data. To manage computational complexity and prevent overfitting, pooling
layers (such as Max Pooling) are used after some convolutional layers.
After feature extraction is complete, the output from the CNN layers—typically in the form of
multi-dimensional arrays—is flattened into a one-dimensional vector. This flattening step
translates spatial patterns into a feature vector that can be used for classification. The flattened
vector is then passed into the Multilayer Perceptron (MLP) block of the model, which serves as
the decision-making engine.
The hidden MLP layers are particularly valuable in intrusion detection because they can learn
complex decision boundaries. For instance, they can distinguish between normal file uploads
and malicious data exfiltration, even if the surface-level behavior looks similar. The ability to
combine and interpret multiple high-level features allows the model to make fine-grained
distinctions—a necessity when dealing with cleverly disguised or multi-stage attacks.
Additionally, MLPs can generalize well from training data, making the model robust against
previously unseen attack patterns.
Once a prediction is made, the output can trigger various actions such as generating alerts,
updating intrusion logs, quarantining affected devices, or adjusting firewall rules. The CNN
layers uncover meaningful patterns in raw traffic data, while the MLP layers interpret these
features to make accurate, real-time decisions. The overall effectiveness of this layer, however,
hinges on the quality of learning that occurs in the hidden CNN and MLP layers—which makes
them the backbone of the system. They transform raw data into actionable insights, enabling
An RBM is a type of generative stochastic neural network that is capable of learning the
probability distribution of input data. Unlike standard feedforward neural networks, RBMs are
designed to discover hidden patterns in data by using unsupervised learning. This makes them
particularly useful for identifying anomalous behavior unknown attack types in network traffic,
which is often hard to label and categorize.
The hidden layer in an RBM is where most of the learning and abstraction happen. Each hidden
neuron tries to detect useful features or patterns that exist in the input. Here's how the hidden
layer becomes vital in an IoT intrusion detection system:
• Feature Discovery: The hidden layer learns to discover patterns that are not explicitly
labeled. It may detect common sequences or statistical irregularities that indicate
suspicious activity.
• Unsupervised Learning: RBMs are unsupervised, so the hidden layer doesn't require
labeled attack data to start learning. This is important for IoT, where new types of
attacks can emerge frequently, and labeled datasets are limited.
• Dimensionality Reduction: The hidden layer compresses high-dimensional network
traffic data into a smaller number of meaningful features, making it easier to analyze
and visualize.
• Anomaly Detection: Once the RBM learns the distribution of normal traffic, any
significant deviation detected by the hidden layer's activation can be flagged as an
anomaly, which might indicate a cyberattack.
The RBM-based intrusion detection process begins with preprocessing, where raw IoT traffic
data is cleaned, normalized, and encoded before being fed into the visible layer. In the training
phase, the RBM uses Contrastive Divergence to learn patterns in normal behavior by
minimizing reconstruction error between input and output. When new data is introduced, the
hidden layer activates neurons based on previously learned patterns. If the input cannot be well
reconstructed, it's flagged as anomalous. This allows the model to detect zero-day attacks or
unknown threats. Although RBMs don’t have an output layer by default, the extracted features
can be passed to a classifier like softmax or logistic regression for final intrusion classification.
Alternatively, detection can rely solely on reconstruction error [Link] hidden layers in
RBMs serve several purposes in the context of real-time intrusion detection for IoT:
• Learning from Unlabeled Data: IoT traffic data is mostly unlabeled. RBMs thrive in
this setting by learning useful features.
• Detecting Unknown Attacks: Because they model what normal behavior looks like,
RBMs can flag any unfamiliar or odd pattern as an anomaly even if it's a completely
new form of attack.
• Flexible Integration: The features from the hidden layer can be used as input to other
models like SVM, Decision Trees, or Deep Neural Networks, making RBMs a great
pre-processing or feature-extraction tool in larger intrusion detection pipelines.
Restricted Boltzmann Machines offer a powerful yet lightweight approach to real-time intrusion
detection in IoT systems. The model’s hidden layers are particularly valuable they learn
underlying structures, recognize normal patterns, and identify anomalies with high accuracy.
Unlike traditional rule-based systems, RBMs adapt to the dynamic nature of IoT environments
and help detect both known and unknown threats. Their ability to function with minimal labeled
data and low computational needs makes them an excellent fit for securing modern IoT
deployments.
[Link]
Deep learning drives many artificial intelligence (AI) applications and services that improve
automation, performing analytical and physical tasks without human intervention. Deep
learning technology lies behind everyday products and services (such as digital assistants,
voice-enabled TV remotes, and credit card fraud detection) as well as emerging technologies
(such as self-driving cars).
Deep neural networks consist of multiple layers of interconnected nodes, each building upon
the previous layer to refine and optimize the prediction or categorization. This progression of
computations through the network is called forward propagation. The input and output layers
of a deep neural network are called visible layers. The input layer is where the deep learning
model ingests the data for processing, and the output layer is where the final prediction or
classification is made.
Another process called backpropagation uses algorithms, like gradient descent, to calculate
errors in predictions and then adjusts the weights and biases of the function by moving
backwards through the layers in an effort to train the model. Together, forward propagation and
backpropagation allow a neural network to make predictions and correct for any errors
accordingly. Over time, the algorithm becomes gradually more accurate.
Deep learning drives many artificial intelligence (AI) applications and services that improve
automation, performing analytical and physical tasks without human intervention. Deep
learning technology lies behind everyday products and services (such as digital assistants,
voice-enabled TV remotes, and credit card fraud detection) as well as emerging technologies
(such as self-driving cars).
5.2 Technologies:
5.2.1 Frontend Interface:
[Link] Flask:
Flask is a lightweight Python micro-framework used to build the frontend interface of the
intrusion detection system. It provides core features like routing, request handling, and
templating via Jinja2, while allowing developers the flexibility to add extensions as needed.
This minimalistic design makes Flask ideal for custom web applications where control over the
architecture is important. In this project, Flask enables smooth integration between the user
interface and the machine learning backend, allowing real-time display of predictions and alerts
with minimal overhead.
5.2.2 Python:
Below are some facts about Python. Python is currently the most widely used multi-purpose,
high-level programming language. Python allows programming in Object-Oriented and
Procedural paradigms. Python programs generally are smaller than other programming
languages like Java. Programmers have to type relatively less and indentation requirement of
the language, makes them readable all the time. The biggest strength of Python is huge
collection of standard libraries which can be used for the following:
• GUI Applications (like Kivy, Tkinter, PyQt etc.)
• Web frameworks like Django (used by YouTube, Instagram, Dropbox)
• Image processing (like Opencv, Pillow)
• Web scraping (like Scrapy, Beautiful Soup, Selenium)
• Test frameworks
• Multimedia
Disadvantages of Python
So far, we’ve seen why Python is a great choice for your project. But if you choose it, you
should be aware of its consequences as well. Let’s now see the downsides of choosing Python
over another language.
• Speed Limitations
• Weak in Mobile Computing and Browsers
• Design Restrictions
• Underdeveloped Database Access Layers
[Link] Tensorflow
TensorFlow is a free and open-source software library for dataflow and differentiable
programming across a range of tasks. It is a symbolic math library and is also widely used for
machine learning applications such as neural networks. TensorFlow is employed for both
research and production at Google and was originally developed by the Google Brain team for
internal use. It was released under the Apache 2.0 open-source license on November 9, 2015.
The library supports deployment across various platforms, including desktops, mobile devices,
and edge systems, making it highly versatile. Its scalable architecture allows for easy training
and deployment of models on both CPUs and GPUs, enabling efficient handling of large
datasets.
[Link] LabelEncoder:
These preprocessing tools from scikit-learn convert text or categorical values into numerical
formats ML models can understand:
LabelEncoder maps each unique class (e.g. “Paris”, “Tokyo”) to an integer (0, 1, 2…), useful
for target labels or ordinal features OneHotEncoder creates binary columns for each category,
avoiding implying order (e.g. Paris → [1,0,0]), essential for non-ordinal features like protocol
types One-hot encoding ensures that categorical variables are represented in a way that doesn't
mislead machine learning models.
[Link] MinMaxScaler:
MinMaxScaler is a widely used normalization technique in data preprocessing that transforms
numeric feature values into a fixed range, typically between 0 and 1. It works by rescaling each
feature individually based on its minimum and maximum values using the formula:
X_scaled = (X – [Link]) / ([Link] – [Link]) × (max – min) + min.
This method is especially important when working with machine learning models that are
sensitive to the scale of input features, such as neural networks, support vector machines, or
gradient descent-based algorithms. Without scaling, features with larger magnitudes can
dominate the learning process, leading to biased models and slower convergence. By ensuring
that all features are on the same scale, MinMaxScaler improves model performance, speeds up
training, and allows for more balanced learning. Additionally, it helps in reducing the impact
of unit disparities between features, making the data more suitable for algorithms that assume
equal importance and distribution of input variables.
types['normal'] = 'normal'
print(types)
if cols[0][0] == 'back':
cols = [Link]([Link][0])
cols.reset_index(drop=True, inplace=True)
cols = [Link](axis=1)
[Link]()
cols[[0,1]] = cols[0].[Link](':',expand = True)
[Link]()
names = cols[0].tolist()
[Link]('label')
[Link] = names
[Link]()
AT_per = AT_count/len(df)*100
AT_per
lab_count = [Link].value_counts()
lab_count
lab_per = lab_count/len(df)*100
lab_per
print("Shape :",[Link])
Department of IT, BRECW Page 40
Detection of Real-time Intrusions & attacks in IOT devices Implementation
Implementation
[Link]().sum().sum()
categorical = df.select_dtypes(include=['object']).columns
print("Categorical features :",categorical)
categorical = [Link]()
print("Categorical features list:",categorical)
[Link]('label')
[Link]('Attack Type')
print("Extracted categorical features list:",categorical)
fig, ax = [Link](figsize=(7, 7))
[Link](x='protocol_type', data=df, ax=ax, palette='Blues_d')
sns.set_style("darkgrid")
for p in [Link]:
[Link](str(p.get_height()),
(p.get_x() * 1.005, p.get_height() * 1.005))
df.protocol_type.value_counts()/len(df)*100
fig, ax = [Link](figsize=(17, 7))
[Link](x='service',data=df,ax=ax,palette='Spectral',
order=df['service'].value_counts().index,linewidth=0)
[Link].value_counts()/len(df)*100
fig, ax = [Link](figsize=(10, 8))
[Link](x='flag',data=df,ax=ax,palette='Blues_r',
order=df['flag'].value_counts().index,linewidth=0)
[Link]()
[Link].value_counts()/len(df)*100
# sum of all the attack types except SF, S0 and REJ
(df['Attack Type'].value_counts().sum() –
df['Attack Type'].value_counts()[0]
- df['Attack Type'].value_counts()[1] –
df['Attack Type'].value_counts()[2])/
(df['Attack Type'].value_counts().sum())*100
fig, ax = [Link](figsize=(15,5))
[Link](x='AttackType',data=df,ax=ax,palette='Greens_r',order=df['Attack
Type'].value_counts().index,linewidth=0)
[Link]()
print("we can see that there are no missing values in the dataset")
[Link]("Missing values in the dataset")
axis.set_xlabel("Features")
axis.set_ylabel("Rows")
[Link]()
Department of IT, BRECW Page 42
Detection of Real-time Intrusions & attacks in IOT devices Implementation
Implementation
high_corr_pairs = high_corr.unstack().sort_values(kind="quicksort",
ascending=False).drop_duplicates()
high_corr_pairs
[Link]('num_root', axis=1, inplace=True)
[Link]('srv_rerror_rate', axis=1, inplace=True)
[Link]('dst_host_srv_rerror_rate', axis=1, inplace=True)
[Link]('dst_host_rerror_rate', axis=1, inplace=True)
[Link]('srv_serror_rate', axis=1, inplace=True)
[Link]('dst_host_srv_serror_rate', axis=1, inplace=True)
[Link]('dst_host_serror_rate', axis=1, inplace=True)
[Link]('dst_host_same_srv_rate', axis=1, inplace=True)
[Link]
[Link]
df['protocol_type'].value_counts()
df['service'].value_counts()
df['flag'].value_counts()
Le = LabelEncoder()
df['protocol_type'] = Le.fit_transform(df['protocol_type'])
df['service'] = Le.fit_transform(df['service'])
df['flag'] = Le.fit_transform(df['flag'])
df['protocol_type'].value_counts()
df['service'].value_counts()
Department of IT, BRECW Page 43
Detection of Real-time Intrusions & attacks in IOT devices Implementation
Implementation
df = [Link](['service'], axis=1)
df['flag'].value_counts()
[Link]()
df.to_csv('processed_kdd.csv', index=False)
scaler = MinMaxScaler()
X = scaler.fit_transform(X)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
y_train = [Link](y_train)
y_test = [Link](y_test)
encoder = OneHotEncoder()
y_train = encoder.fit_transform(y_train.reshape(-1, 1)).toarray()
y_test = encoder.fit_transform(y_test.reshape(-1, 1)).toarray()
## checking how a model performs with different learning rates
plt.tight_layout()
[Link]()
X_train.shape[1]
opt = Adam(learning_rate=0.001)
model = Sequential()
[Link](Dense(X_train.shape[1], input_dim=X_train.shape[1], activation='relu'))
[Link](Dense(12, activation='relu'))
[Link](Dense(5, activation='softmax'))
Department of IT, BRECW Page 45
Detection of Real-time Intrusions & attacks in IOT devices Implementation
Implementation
[Link](loss='categorical_crossentropy', optimizer=opt, metrics=['accuracy'])
trials = [Link](X_train, y_train, epochs=10, validation_split=0.2, batch_size=64)
plot_model(model, to_file='model_diagram.png', show_shapes=True, show_layer_names=True)
# ann_viz(model, title="Neural Network Model",view=True, filename="[Link]")
fig, ax = [Link](figsize=(15, 15))
[Link]([Link]['accuracy'])
[Link]([Link]['val_accuracy'])
[Link]('model accuracy')
[Link]('accuracy')
[Link]('epoch')
[Link](['train', 'test'], loc='upper left')
[Link]()
loss, accuracy = [Link](X_test, y_test)
print(loss, accuracy)
[Link](loss, accuracy)
[Link]('Loss vs Accuracy')
[Link]('Loss')
[Link]('Accuracy')
[Link]()
[Link]('NN_model.h5')
activationFunction='relu'
def CNN()
cnnmodel = Sequential()
[Link](Conv1D(filters=128,kernel_size=2,
activation='relu',input_shape=(X_train.shape[1],X_train.shape[2])))
[Link](MaxPooling1D(pool_size=2))
[Link](Dropout(rate=0.2))
[Link](Flatten())
[Link](Dense(5, activation='softmax'))
[Link](optimizer='adam', loss='categorical_crossentropy',metrics=['accuracy'])
[Link]()
cnnmodel = CNN()
[Link]([Link]['accuracy'])
[Link]([Link]['val_accuracy'])
[Link]('accuracy')
[Link]('epoch')
[Link]()
[Link]([Link]['loss'])
[Link]([Link]['val_loss'])
[Link]('loss')
[Link]('epoch')
[Link]()
cnn_predict=[Link](cnnpredictions,axis=1)
y_pred = [Link](y_pred,axis=1)
#y_prob = cnnmodel.predict_proba(X_test)[:, 1]
#storeResults('CNN',cnn_acc,cnn_prec,cnn_rec,cnn_f1)
storeResults('CNN',cnn_acc,cnn_prec,cnn_rec,cnn_f1)
6. Screenshots
Screenshot 7: Homepage
Features to be tested
• Verify that we get proper output
• Verify that all painters and eraser work
• Unit testing: Unit testing involves the design of test cases that validate that the internal
program logic is functioning properly, and that program inputs produce valid outputs.
All decision branches and internal code flow should be validated. It is the testing of
individual software units of the application .it is done after the completion of an
individual unit before integration. This is a structural testing, that relies on knowledge
of its construction and is invasive.
Unit tests perform basic tests at component level and test a specific business process,
application, and/or system configuration. Unit tests ensure that each unique path of a
business process performs accurately to the documented specifications and contains
clearly defined inputs and expected results.
• System Test: System testing ensures that the entire integrated software system meets
requirements. It tests a configuration to ensure known and predictable results. An
example of system testing is the configuration-oriented system integration test. System
testing is based on process descriptions and flows, emphasizing pre-driven process links
and integration points.
• White Box Testing: White Box Testing is a testing in which in which the software
tester has knowledge of the inner workings, structure and language of the software, or
at least its purpose. It is purpose. It is used to test areas that cannot be reached from a
black box level.
• Black Box Testing: Black Box Testing is testing the software without any knowledge
of the inner workings, structure or language of the module being tested. Black box tests,
as most other kinds of tests, must be written from a definitive source document, such
asspecification or requirements document, such as specification or requirements
document. It is a testing in which the software under test is treated, as a black box you
cannot “see” into it. The test provides inputs and responds to outputs without
considering how the software works.
Test Cases
The proposed deep learning-based Intrusion Detection System (IDS) achieved significant
improvements in detecting real-time cyber threats in IoT environments. The system was tested
using three benchmark datasets, which are widely used in intrusion detection research. Various
deep learning models, including CNN, DNN+MLP, RBM and RNN were implemented and
evaluated. Among these, the DNN+MLP hybrid model consistently outperformed others,
achieving up to 99% accuracy, especially in complex and evolving attack scenarios.
In addition to the high accuracy rates demonstrated by the hybrid models, the experimental
results also highlight the robustness of the proposed approach under varying network traffic
conditions. The models maintained consistent performance even when subjected to imbalanced
data distributions and noisy environments, which are common in real-world IoT systems.
Notably, the RBM and DNN+MLP models showed strong generalization capabilities,
effectively identifying previously unseen attack types with minimal performance degradation.
This suggests the system's ability to adapt and respond to evolving threat patterns without
requiring frequent retraining. The combination of deep feature extraction and temporal
sequence learning proved essential in achieving reliable, real-time intrusion detection suitable
for deployment in dynamic and distributed IoT networks.
The results confirmed that combining multiple deep learning architectures and ensemble
methods enhanced detection reliability, reduced computational overhead, and maintained
system integrity. The approach is scalable and adaptable to new threats, making it a robust
cybersecurity solution for modern IoT infrastructures.
8. Conclusion
This paper discusses the involving challenges and limitations in previous studies, which have been
investigating how to use deep learning in the early detection and eradication of cyber threats. We
emplys deep learning techniques for cyber-attack malware detection, such as identification and
discriminative. However, we summarized the seven approaches, i.e., deep learning (RNN, CNN,
and DNN) and generative models/methods (RBN, DBN, DBM., and DA). In addition, our
investigation focuses on accuracy and provided dictionaries in the research field. The
experimentation of our work demonstrates IDS and Cybersecurity attacks, which are detected
successfully using a collaborative technological environment. Also, we have investigated to find
which DL techniques performed better among the others. According to this analysis, the use of
deep learning methods increases the investigational rate of classification intrusion while providing
a robust performance of state-of-the-art supervised systems. In this scenario, a part of future work,
this study extended to include advanced deep learning methods and transfer learning approaches.
Moreover, the robustness of the supervised system is validated using IDS training. Thus, when
designing a newfangled Intrusion Detection System (IDS), the properties can be used in the real-
time system to detect internal and external intruders and their malicious behaviors.
[Link] Scope
The future scope of the project envisions the integration of advanced deep learning techniques,
transfer learning can be employed to leverage pre-trained models, reducing the need for extensive
data and computational resources. The system can be scaled and customized for use by various
firms and multinational corporations (MNCs) to safeguard intellectual property and digital assets.
Incorporating edge computing will allow real-time threat detection directly on IoT devices,
minimizing latency and improving system responsiveness. This also helps in optimizing
bandwidth usage and reducing dependency on centralized servers. Federated learning can be
utilized to collaboratively train models across multiple organizations without transferring sensitive
data. This approach ensures data privacy while contributing to the development of a more
generalized and robust global model. The combination of edge and federated learning provides a
decentralized yet secure framework for threat intelligence. Enhanced model explain ability and
self-learning capabilities can be introduced for adaptive threat mitigation.
[Link]
[1] Y. LeCun, Y. Bengio, and G. Hinton, ‘‘Deep learning,’’ Nature, vol. 521, no. 7553, pp. 436–
444, 2015.
[4] A. Ahmim, M. Derdour, and M. A. Ferrag, ‘‘An intrusion detection system based on combining
probability predictions of a tree of classifiers,’’ Int. J. Commun. Syst., vol. 31, no. 9, p. e3547,
Jun. 2018.
[5] A. Ahmim, L. Maglaras, M. A. Ferrag, M. Derdour, and H. Janicke, ‘‘A novel hierarchical
intrusion detection system based on decision tree and rules-based models,’’ in Proc. 15th Int. Conf.
Distrib. Comput. Sensor Syst. (DCOSS), May 2019, pp. 228–233.
[6] Z. Dewa and L. A. Maglaras, ‘‘Data mining and intrusion detection systems,’’ Int. J. Adv.
Comput. Sci. Appl., vol. 7, no. 1, pp. 1–10, 2016.
[7] B. Stewart, L. Rosa, L. A. Maglaras, T. J. Cruz, M. A. Ferrag, P. Simoes, and H. Janicke, ‘‘A
novel intrusion detection mechanism for SCADA systems which automatically adapts to network
topology changes,’’ EAI Endorsed Trans. Ind. Netw. Intell. Syst., vol. 4, no. 10, p. e4, 2017.
[8] M. A. Ferrag, L. Maglaras, S. Moschoyiannis, and H. Janicke, ‘‘Deep learning for cyber
security intrusion detection: Approaches, datasets, and comparative study,’’ J. Inf. Secur. Appl.,
vol. 50, Feb. 2020, Art. no. 102419.
[9] Y. Imrana, Y. Xiang, L. Ali, and Z. Abdul-Rauf, ‘‘A bidirectional LSTM deep learning
approach for intrusion detection,’’ Expert Syst. Appl., vol. 185, Dec. 2021, Art. no. 115524.
[11] J. Azevedo and F. Portela, ‘‘Convolutional neural network—A practical case study,’’ in Proc.
Int. Conf. Inf. Technol. Appl. Singapore: Springer, 2022, pp. 307–318.
[12] K. He, X. Zhang, S. Ren, and J. Sun, ‘‘Deep residual learning for image recognition,’’ in
Proc. IEEE Conf. Comput. Vis. Pattern Recognit. (CVPR), Jun. 2016, pp. 770–778.
[13] J. Yosinski, J. Clune, Y. Bengio, and H. Lipson, ‘‘How transferable are features in deep neural
networks?’’ in Proc. Adv. Neural Inf. Process. Syst., vol. 27, 2014, pp. 1–9.
[14] G. Awad, C. G. Snoek, A. F. Smeaton, and G. Quénot, ‘‘Trecvid semantic indexing of video:
A 6-year retrospective,’’ ITE Trans. Media Technol. Appl., vol. 4, no. 3, pp. 187–208, 2016.
[15] C. Szegedy, V. Vanhoucke, S. Ioffe, J. Shlens, and Z. Wojna, ‘‘Rethinking the inception
architecture for computer vision,’’ in Proc. IEEE Conf. Comput. Vis. Pattern Recognit. (CVPR),
Jun. 2016, pp. 2818–2826.
[16] M. Uddin, R. Alsaqour, and M. Abdelhaq, ‘‘Intrusion detection system to detect DDoS attack
in Gnutella hybrid P2P network,’’ Indian J. Sci. Technol., vol. 6, no. 2, pp. 71–83, 2013.
[17] R. L. Haupt and S. E. Haupt, Practical Genetic Algorithms. Wiley, 2004, doi:
10.1002/0471671746.
[18] D. Hossain, G. Capi, and J. M., ‘‘Optimizing deep learning parameters using genetic
algorithm for object recognition and robot grasping,’’ J. Electron. Sci. Technol., vol. 16, no. 1, pp.
11–15, 2018.
[19] O. E. David and I. Greental, ‘‘Genetic algorithms for evolving deep neural networks,’’ in
Proc. Companion Publication Annu. Conf. Genetic Evol. Comput., Jul. 2014, pp. 1451–1452.
[21] J. Azevedo and F. Portela, ‘‘Convolutional neural network—A practical case study,’’ in Proc.
Int. Conf. Inf. Technol. Appl. Singapore: Springer, 2022, pp. 307–318.