IntrusiondetectionUsing ML
IntrusiondetectionUsing ML
Abstract—As cyberattacks grow in prevalence, Intrusion attacks originating from the type of phishing attack that occurs
Detection Systems (IDS) have become critical for securing with the use of phish emails [1]. The ransomware attacks grew
network infrastructures. This study proposes an efficient IDS with 70% of the attacks focusing on the small business market
framework utilizing both machine learning (ML) and deep and the number of ransomware teams actively present more than
learning (DL) algorithms. The framework is evaluated on the “NF- doubling year over year [1].
UNSW-NB15-v2” dataset, which comprises a blend of normal and
malicious traffic. A diverse set of advanced models—including Adversaries now leverage automation and AI to accelerate
Deep Neural Networks (DNN), Long Short-Term Memory reconnaissance, weaponization, and evasion, fueling an arms
(LSTM) networks, eXtreme Gradient Boosting (XGBoost), race that compels defenders to adopt more adaptive, data-driven
Random Forest (RF), and K-Nearest Neighbors (KNN)—is countermeasures [2].
deployed for intrusion detection. The approach encompasses both
binary classification (normal vs. malicious) and multi-class Traditional intrusion detection systems (IDS) that rely on
classification (specific attack categories). Preprocessing steps static signatures or hand-crafted rules struggle with previously
include feature standardization using StandardScaler, class unseen or rapidly morphing threats [3]. Machine learning (ML)
imbalance correction via SMOTE, and dimensionality reduction and artificial intelligence (AI) enable dynamic threat modeling,
through Principal Component Analysis (PCA). Results show that anomaly detection, and behavioral analysis, allowing IDSs to
Random Forest and XGBoost models achieve high accuracy in generalize to novel attacks while reducing false positives [3].
binary classification with F1-scores approaching 0.97, while
XGBoost attains the best macro F1-score (0.71) in multi-class Despite notable advancements in IDS research, a critical
tasks. Additionally, RF and XGBoost demonstrate the fastest limitation persists across most studies: the insufficient handling
inference times, underscoring their suitability for real-time of class imbalance, which leads to poor detection rates for
deployment. This work contributes a scalable and optimized IDS minority attack types. Previous works have primarily focused on
pipeline for enhancing cybersecurity resilience. maximizing overall accuracy, often at the expense of rare class
detection, resulting in inflated performance metrics dominated
Keywords—Cybersecurity; cyber-attack; intrusion detection by frequent categories. Furthermore, inconsistencies in
system; machine learning; deep learning preprocessing pipelines, a lack of standardized evaluation on
modern NetFlow-based datasets like NF-UNSW-NB15-v2, and
I. INTRODUCTION the limited integration of a diverse set of both machine and deep
In recent years, the cyber world witnessed the most learning techniques within a single, optimized framework limit
phenomenal increase ever of cyber threats that targeted the robustness and practical applicability of existing IDS
individuals, businesses, and governments. The cost of solutions. This study aims to bridge these gaps by proposing an
cybercrime at the global level is anticipated at $9.5 trillion by integrated pipeline that combines SMOTE-based class
2024, which amounts to $26 billion per day or $18 million per balancing, PCA-driven feature reduction, and a comprehensive
minute [1]. The growing rate of cybercrime emphasizes the need evaluation of multiple ML and DL models to enhance minority
for proper cybersecurity controls. class detection and overall performance on the NF-UNSW-
NB15-v2 dataset.
Small and medium-sized businesses are most vulnerable
with 69% of these experiencing at least one cyber-attack within The remainder of the paper is organized as follows. Section
the past year [1]. Yet 80% of the SMBs are largely II reviews related work on ML/DL-based IDS. Section III details
unimplemented with the utilization of Privileged Access the methodology, including the dataset, preprocessing
Management solutions while fewer than 60% of the enterprises (standardization, imbalance handling, dimensionality reduction,
are using vital cybersecurity practices of password managers, and train–test split), model specifications, and evaluation
two-factor authentication, and cybersecurity education [1]. The metrics. Section IV reports the experimental results for both
shift toward remote work amplified the fear of security since binary and multi-class settings and examines inference-time
72% of businesses are concerned about the danger it presents performance for real-time applicability. Section V discusses key
and 80% of cybersecurity professionals confirm that the danger findings, practical implications, and limitations. Section VI
increased since 2020 [1]. concludes and outlines directions for future research.
Phishing and ransomware attacks grew more complex and II. RELATED WORK
more numerous. Security professionals saw 62% more phishing
Kasongo and Sun [4] conducted a performance analysis of
assaults within the recent years with 79% of account takeover
Intrusion Detection Systems (IDS) by applying a feature
440 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
selection algorithm to the UNSW-NB15 dataset. They and compared over seven datasets, with the consequence that
emphasized the importance of reducing feature dimensionality single classifiers fall below both ensemble and hybrid classifiers
to enhance IDS accuracy. The study used five machine learning in terms of accuracy and detection performance. Comparison
classifiers—SVM, KNN, Logistic Regression, Artificial Neural between algorithms including SVM, DTs, RF, and Neural
Networks (ANN), and Decision Trees (DT)—and showed that Networks identifies that ensemble approaches, including
XGBoost-based feature selection significantly improved model stacking classifiers, have a significant impact in intrusion
performance, especially for DTs. However, the study did not detection improvement. Challenges include feature selection
address class imbalance, which led to lower F1-scores for improvement, testing over a range of and updated datasets, and
minority classes. minimizing false positive values. Optimizing hybrid models,
minimizing computational overload, and enhancing real-time
Kumar et al. [5] proposed an integrated rule-based IDS using intrusion capabilities have been suggested for future work,
both the UNSW-NB15 and RTNITP18 datasets. Their approach according to the authors.
employed Decision Tree classifiers (C5, CHAID, CART, and
QUEST) to detect five attack types: Generic, Probe, DoS, Samantaray et al. in [9] conducted a comparative study on
Exploit, and Normal. The study reported improved accuracy and ML model implementation in intrusion detection in IoT-based
reduced false alarm rates through rule-based modeling and networks. The research is centered on increasing threats in the
information gain-based feature selection. Nonetheless, it lacked security of IoT networks and the need to utilize efficient IDS in
proper handling of class imbalance and yielded low precision order to mitigate them. The research uses the “UNSW-NB15
and recall for critical attack types. (DS-1)” and “NF-UNSW-NB15 (DS-2)” datasets in comparing
models based on ML like SVM, KNN, Logistic Regression,
More et al. [6] compared several supervised ML techniques Naïve Bayes, DT, and RF. The feature scaling is based on a
for identifying deceitful emails with filtering approaches and method involving the usage of the MaxAbsScaler algorithm in
through use of the WEKA toolset. The work identifies a order to increase efficiency in classification. The results
weakness in conventional Bayesian filtering, effective in spam highlight the usage of the RF classifier in achieving the highest
filtering but not in high false positive cases. To counteract,
precision in generating the most accurate outcome with a gain in
several classifiers, such as RF and SVM, have been incorporated the rate of detection from 60% to 94% in the DS-2 dataset. The
and utilized for enhancing accuracy and minimizing false research focuses on efficiency in ML usage in intrusion
positives in classification. In its use, feature extraction via Naïve detection and supports future research on implementation with
Bayes and an evaluation tool developed in WEKA facilitated improved feature selection and DL.
testing of numerous algorithms for classification in a thorough
manner. Experimental tests showed that RF and SVM Sayed et al. in [10] conducted research with a focus on
performed better in enhancing positive and negative actual optimizing the efficiency of DNN-driven IoT intrusion detection
values and overall accuracy over 96%. The work identifies the systems (IDS). Because the IoT devices are under threat and
use of hybrid classification approaches in improving deceitful there is a limitation in the process ability and in features in
message detection and minimizing security threats posed security, the researchers provided two CNN models, namely
through spammers. IoTCNN and MyCNN, with a purpose to classify intrusion in
the network. The "NF-UNSW-NB15-v2" dataset was used in the
Tahri et al. [7] have designed an IDS with ML algorithms for research, and the stream network data was converted into RGB
enhancing network security. As communications through images in order to train the models. Results indicated the
electronic means have increased, IDS proves to be a useful tool efficiency of the models in the detection of various intrusion
for discovering hostile activity in network communications. In types, and in the majority of intrusion categories, the precision
the current work, three classifiers, Naïve Bayes, SVM, and of the models improved. The research confirms the efficiency of
KNN, have been compared for performance with two anomaly-based IoT security based on DL and calls for
benchmark datasets, namely, “NSL-KDD” and “UNSW- improvement in the handling of imbalances in the class and the
NB15”. In part one of work, three classifiers have been optimization of the hyperparameters.
compared with the use of “UNSW-NB15”, and then for a proper
analysis, best-performing algorithm is utilized for testing with Table I provides a structured summary of key related studies,
“NSL-KDD”. As per work, SVM outperforms all classifiers in highlighting the datasets, methodologies, and performance
terms of accuracy consistently, with 97.77% accuracy for metrics used, which helps position the present work within the
“UNSW-NB15” and 97.29% accuracy for NSL-KDD. In broader landscape of IDS research.
conclusion, SVM proves to be an effective intrusion detection
classifier, and future work will attempt to make its processing Despite notable advancements in IDS research, a recurring
efficient and integrate it in real-time security tools such as a limitation across most studies is the insufficient handling of
firewall. class imbalance and the resulting poor detection of minority
attack types. Previous works primarily focused on improving
Musa et al. [8] review the application of ML algorithms in overall accuracy without explicitly addressing the critical
IDS for enhancing network security through observation of challenge of rare class detection, often leading to inflated
traffic and intrusion activity, and IDS is distinguished between performance metrics dominated by frequent attack categories. In
anomaly-based and signature-based detection, with the first addition, inconsistencies in preprocessing, lack of standardized
identifying abnormalities in behavior and the second employing evaluation on newer datasets, and limited integration of deep
predefined attack signatures. Various types of ML approaches, learning techniques further limit the robustness of existing IDS
including single, hybrid, and ensemble classifiers, are contrasted solutions. Building on these gaps, this research proposes an
441 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
integrated approach combining SMOTE-based class balancing, minority class detection and overall intrusion detection
PCA-driven feature selection, ML/DL modeling to enhance performance on the NF-UNSW-NB15-v2 dataset [20].
442 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
443 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
Table III lists the feature set of the NF-UNSW-NB15 types, “Exploits” and “Fuzzers” appear most frequently, while
dataset, detailing the flow characteristics captured for intrusion others such as “Reconnaissance,” “DoS,” and especially
detection analysis. “Worms” occur far less often. This imbalance poses challenges
for accurate model training and may necessitate the use of
Fig. 2 illustrates the significant class imbalance in the resampling methods or advanced techniques to improve
dataset, with benign (normal) traffic overwhelmingly detection performance, particularly for minority attack classes.
dominating all categories of malicious traffic. Among the attack
444 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
445 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
characteristics of both points, resulting in a new example that is An initial correlation analysis of the raw NetFlow features
both realistic and non-redundant [32]. revealed strong linear relationships among several variables. For
instance, IN_PKTS and OUT_PKTS exhibited a Pearson
By enriching the training set with these synthetic examples, correlation coefficient of approximately 0.99, while
the class distribution becomes more balanced. This allows FLOW_DURATION_MILLISECONDS was highly correlated
learning algorithms to be exposed to a wider variety of patterns with both DURATION_IN and DURATION_OUT. Similarly,
and variations within the minority classes, which enhances their MIN_TTL and MAX_TTL showed correlations exceeding 0.90.
ability to generalize and improves detection of rare attack types. These relationships, visualized in Fig. 5, support the application
The test set was left untouched to preserve the original of PCA to reduce multicollinearity and noise within the dataset.
distribution and maintain the integrity of the evaluation.
To validate the independence of the PCA components, a
3) Dimensionality reduction: To address the high correlation matrix was generated to examine the relationships
dimensionality of the dataset, which consists of 43 flow-based between the extracted components. As shown in Fig. 6, the
NetFlow features, Principal Component Analysis (PCA) was components are effectively uncorrelated, demonstrating that
employed as an effective dimensionality reduction technique. PCA successfully transforms the original feature space into a set
PCA transforms the original feature set into a smaller number of orthogonal, linearly independent dimensions. This
of uncorrelated components while retaining the majority of the orthogonality reinforces PCA’s suitability for improving model
data’s variance. This transformation reduces computational robustness and reducing feature redundancy.
complexity, accelerates model training, and mitigates the risk Overall, PCA proved especially beneficial for ensemble
of overfitting by eliminating redundant or less informative models such as Random Forest and XGBoost, which can be
attributes [13]. negatively affected by irrelevant or highly correlated features.
Its use enhanced model focus, reduced overfitting, and improved
interpretability within the intrusion detection pipeline.
446 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
4) Train-test split: To evaluate model performance fairly, b) Random Forests (RF): RF is a versatile algorithm in
the dataset is divided into distinct subsets. For traditional ML, famous for reducing the effect of overfitting, a prevalent
machine learning models, the dataset is partitioned into 70% for problem in decision trees (DTs). It performs tasks such as
training and 30% for testing to evaluate generalization classification, regression, and others by building many DTs
performance on unseen data. In the case of deep learning during the training period. The algorithm works by evaluating
models such as LSTM and DNN, the dataset is further divided multiple distinct decision trees (DTs) and making the prediction
into 70% for training and 30% for testing, enabling effective through a voting mechanism. Unlike in the case of a standard
monitoring during training and ensuring robust model DT, in which each internal node gets partitioned by the optimal
evaluation. attribute, RF uses the optimal attribute from a random subset of
predictors at each internal node. This randomization serves to
D. Modeling enhance model generalization and resistance, and the resulting
1) Machine learning models: Random Forest (RF), KNN, algorithm is a versatile tool in numerous applications in ML.
XGBoost, and SVM are the most effective ML models for the c) XGBoost (XGB): XGBoost (XGB) is a Gradient Tree
detection of intrusions. The models are good for classification Boosting algorithm powerful enough to solve heavy-scale ML
with feature-extracted input but are inefficient with complex problems in an efficient and effective manner. It possesses great
temporal relationships within sequential input. prediction precision and model training speed, and it's the
a) K-Nearest Neighbor (KNN): The KNN algorithm is a leading performer in all the competitions at Kaggle. The
supervised algorithm in ML most commonly used to classify mechanism in XGB lies in the addition of trees in an iterative
tasks [11]. It identifies the unlabeled data by considering the fashion and the division of the features during the course of the
label and the available training data's features. The algorithm expansion in the tree. The model learns to fit the residuals from
identifies the data by determining the point's nearest neighbors the last prediction each time a new tree gets added [13]. Given
and the final label by majority voting. Among all the algorithms an input 𝑥𝑖 , a true label 𝑦𝑖 , and a raw prediction 𝑧𝑖 before
in ML, the algorithm in the case of the KNN algorithm is unique applying the sigmoid function, according to [14], the XGBoost
in terms of ease and interpretability and, in turn, acts to be a model defines its objective function in the following equation:
(𝑡−1)
commonly used algorithm to classify tasks [12]. Even despite 𝐿(𝑡) = ∑𝑛𝑖=1 𝑙 (𝑦𝑖 , 𝑍𝑖 + 𝑓𝑡 (𝑥𝑖 )) + 𝛺(𝑓𝑡 ) + 𝑐
the ease, the algorithm performs exceptionally in the case of
solving the classification and the regression problems in Where 𝑙(.,.) represents the loss function, t denotes the t-th
different datasets, regardless of size, label distribution, the tree, and Ω serves as a penalty for model complexity. The term
datasets' noise, and the datasets' ranges [12]. 𝛺(𝑓𝑡 ) refers to the regularization penalty, while c is a constant.
447 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
The second-order Taylor expansion is given by: b) Long Short-Term Memory (LSTM): The LSTM layer is
a special kind of [18] RNN, and the main job of the LSTM layer
𝑓(𝑥 + 𝛥𝑥) ≈ 𝑓(𝑥) + 𝑓 ′ (𝑥)𝛥𝑥 + 1⁄2 𝑓 ′′ (𝑥)𝛥𝑥 2
is to handle sequence data with temporal relationships, such as
By substituting Eq. (2) into Eq. (1), we can obtain the text and relation data. The LSTM layer consists of three gates,
following result. the forget gate, the output gate, and the input gate, and the shared
1 2 state. The use equation and the LSTM layer's detailed working
𝐿(𝑡) ≈ ∑𝑛𝑖=1 [𝑙(𝑦𝑖 + 𝑍𝑖(𝑡−1) ) + 𝑔𝑖 𝑓𝑡 (𝑥𝑖 ) + ℎ𝑖 (𝑓𝑡 (𝑥𝑖 )) ] are presented in the following equations:
2
𝑓𝑠 = 𝜎(𝑊𝑓 ⋅ [ℎ𝑠−1 , 𝑥𝑠 ] + 𝑏𝑓 )
where 𝑔𝑖 = 𝜕 𝐿⁄𝜕 𝑧𝑖 , and ℎ𝑖 = 𝜕 2 𝐿⁄𝜕 𝑧𝑖2 . By eliminating
the constant terms, we derive the following simplified objective 𝑖𝑠 = 𝜎(𝑊𝑓 ⋅ [ℎ𝑠−1 , 𝑥𝑠 ] + 𝑏𝑖 )
at step 𝑡.
𝐶´ = 𝑡𝑎𝑛ℎ(𝑊𝑐 ⋅ [ℎ𝑠−1 , 𝑥𝑠 ] + 𝑏𝐶 )
1 2
𝐿(𝑡) ≈ ∑𝑛𝑖=1 [𝑔𝑖 𝑓𝑡 (𝑥𝑖 ) + ℎ𝑖 (𝑓𝑖 (𝑥𝑖 )) ] + 𝛺(𝑓𝑡 )
2 𝐶𝑠 = 𝑓𝑠 ⋅ 𝐶𝑠−1 + 𝑖𝑠 ⋅ 𝐶´
The terms 𝑔𝑖 and ℎ𝑖 play a vital role in optimizing the 𝑜𝑠 = (𝑊𝑜 [ℎ𝑠−1 , 𝑥𝑠 ] + 𝑏𝐶 )
XGBoost training process. For binary classification, the model
typically employs cross-entropy (CE) as its default loss function. ℎ𝑠 = 𝑜𝑠 ⋅ 𝑡𝑎𝑛(𝐶𝑠 )
𝐿= − ∑𝑛𝑖=1[𝑦𝑖 𝑙𝑜𝑔(𝑦´𝑖 ) − (1 − 𝑦𝑖 )𝑙𝑜𝑔(1 − 𝑦´𝑖 )] The input gate controls how the LSTM cell state acquires the
information, in Eq. (9). The forget gate controls how the LSTM
In Eq. (5), 𝑦´𝑖 = 1⁄[1 + 𝑒𝑥𝑝(−𝑧𝑖 )] , that is sigmoid is cell state forget the information, in the Eq. (8). The cell state
selected as activation. Therefore, we can get: updates by the Eq. (10) and Eq. (11).
𝜕 𝑦´𝑖 ⁄𝜕 𝑧𝑖 = 𝑦´𝑖 (1 − 𝑦´𝑖 ) Output Layer:
2) Deep learning models: Deep-learning methods often fall The output layer generates the predicted sentiment
under the umbrella of unsupervised pre-trained networks— classification of the comment. The final output vector is scaled
architectures that stack many more layers and parameters than using the softmax activation function to produce a probability
typical machine-learning neural nets, earning them the distribution across each class. The equation is as follows:
designation “deep.” 𝑦 = 𝑠𝑜𝑓𝑡𝑚𝑎𝑥(𝑊ℎ𝑓𝑐 + 𝑏)
a) Deep Neural Network (DNN): An Artificial Neural
Network (ANN) is a model based on the structure and function E. Evaluation Metrics
of the brain [15]. Since neural networks (NN) are powerful 1) Confusion matrix: It's a matrix to represent how model
nonlinear discriminators in the event of problems in classify dataset, also to use to check how good the model's
classification, because they are able to describe any decision performance of classification. It's comprised by four
boundary in the feature space [16]. In recent years, Deep Neural components.
Networks (DNNs) gained significant interest in intrusion
detection research and evolved from Shallow Neural Networks In a confusion-matrix context, true positives (TP) are cases
(SNNs). The feature abstraction ability in DNNs and the ability where an instance is genuinely positive and the model correctly
to represent highly complex patterns make them extremely labels it as such, whereas true negatives (TN) are instances that
useful in applications in DL. Because of their ability to represent are truly negative and rightly classified as negative. By contrast,
false positives (FP) occur when a genuinely negative instance is
data in a good way, DNNs are in high demand in order to design
mistakenly flagged as positive, and false negatives (FN) arise
efficient and robust solutions.
when a genuinely positive instance is incorrectly marked as
The results are produced in a DNN based on the connection negative.
weights and activation functions in the neurons. The DNN is
composed of multiple processing layers, and every layer 2) ROC Curve (Receiver Operating Characteristic Curve):
contributes to decision-making and feature extraction. Several A graph that shows classification performance across all
hyperparameters dictate the operation of a DNN and are to be thresholds by plotting the true-positive rate (TPR) against the
determined in advance, including the number of units, number false-positive rate (FPR), illustrating the trade-off between
of layers, weights and bias initializers, activation function, sensitivity and specificity.
regularizer's coefficient, learning rate, and the optimizer. In this 3) Score: The harmonic mean of precision and recall; a
DNN model, ReLU activation is applied in the input layer and
single, balanced metric that is especially informative when
in every hidden layer. The ReLU function is a piecewise linear
function and returns the same input in the situation where the class distributions are unbalanced. It ranges between 0 and 1,
input is a positive number and a value of zero in the situation and 1 in the event of optimal precision and recall.
where the input is a negative number [17]. The neurons activated 2∗ Precision ∗ Recall
by this function are also rectified linear activation units. F1 Score = (15)
Precision + Recall
448 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
4) Accuracy: The rate of correctly classified observations Moreover, AUC scores, which evaluate a model’s ability to
over the total observations. It is a helpful indicator in the distinguish between classes, were also affected. Deep learning
situation where false positives and false negatives are equally models such as DNN and LSTM yielded relatively lower AUCs
distributed. in the range of 0.90–0.92, suggesting less reliable separability
between benign and malicious traffic. In contrast, ensemble
Accuracy =
Number of Correct Predictions
(16) models like Random Forest and XGBoost performed better,
Total Number of Predictions achieving AUC scores around 0.98. Nevertheless, even these
models demonstrated measurable improvements after applying
5) Precision: The proportion of the total predicted positives
SMOTE.
actually being positives. The higher the precision, the lower the
rate of the incorrect positives, and the lowest the incorrect These findings confirm that SMOTE plays a critical role not
positives. only in enhancing recall and F1-scores but also in improving the
True Positives overall discriminative power of classifiers, as reflected in AUC
Precision = (17) metrics. Table V summarizes the performance of LSTM, DNN,
True Positives + False Positives
Random Forest, KNN, and XGBoost on the binary classification
6) Recall: The ratio of correctly predicted positive task prior to applying SMOTE.
instances to all actual positive instances. A higher recall
indicates fewer missed positives and a lower rate of false After applying SMOTE, all models demonstrate strong
performance, with Random Forest and KNN achieving high
negatives.
True Positives
accuracy and F1-scores. While LSTM and DNN yield slightly
Recall = (18) lower precision for the Attack class, they still achieve perfect
True Positives + False Negatives
recall, indicating high sensitivity to positive cases. The AUC
IV. RESULTS score of 0.99 or higher across all models confirms excellent
separability between classes. Among all models, RF achieved
This section presents how a range of ML and DL models
the best overall performance with an F1-score of 0.97, and
performed on binary and multi-class intrusion-detection tasks
using the “NF-UNSW-NB15” dataset. Before training, we highly balanced precision and recall values, especially for class
applied PCA to cut dimensionality and boost both speed and 1 (Attack class). Its confusion matrix is very high, showing low
misclassificationwith 2308 false positives and 199 false
accuracy. Every model was tuned with the same hyper-
negative, Fig. 7 shows Random Forest confusion matrix that
parameter settings to keep the comparison fair. Their
effectively classified both Normal and Attack classes, making it
effectiveness was gauged with a full suite of metrics—accuracy,
the most reliable model for the binary classification task.
precision, recall, F1-score, AUC, and confusion matrices—so
we could see each algorithm’s strengths and weaknesses in TABLE IV. HYPERPARAMETER SETTINGS
detail. Results are split into two categories: binary detection of
normal versus malicious traffic, and multi-class detection that Parameter Value
pinpoints the exact attack type. Epochs 20
A. Hyperparameter Configuration Batch Size 128
All deep learning models (LSTM and DNN) were trained Learning Rate 0.001
using a fixed set of hyperparameters to ensure a fair and
Optimizer Adam
consistent comparison. For binary classification tasks, the loss
function employed was binary crossentropy, while sparse Loss Function (Binary) Binary Crossentropy
categorical crossentropy was used for multi-class classification. Loss Function (Multi) Sparse Categorical Crossentropy
Model optimization was performed using the Adam optimizer
PCA Components (Binary and Multi) 20
with a learning rate of 0.001. Both tasks were trained over 20
epochs with a batch size of 128. Additionally, early stopping was
applied based on validation loss to prevent overfitting and TABLE V. BINARY CLASSIFICATION PERFORMANCE WITHOUT SMOTE
ensure optimal generalization performance. Model Accuracy Precision Recall F1-score AUC
Table IV presents the hyperparameter settings used for LSTM 0.99 0.97 0.92 0.94 0.92
model training, including learning configuration, optimization
DNN 0.99 0.97 0.90 0.93 0.90
strategy, and loss functions for both binary and multi-class tasks.
RF 0.99 0.97 0.98 0.98 0.98
B. Binary Classification Results
KNN 0.99 0.95 0.95 0.94 0.95
Before applying SMOTE, all models achieved high overall
accuracy (0.99); however, recall and F1-scores—particularly for XGBoost 0.99 0.96 0.97 0.97 0.98
the minority class—were comparatively lower. For instance, the
Fig. 8 shows LSTM confusion matrix for classifying both
LSTM model achieved a recall of 0.92 and an F1-score of 0.94,
Normal and Attack classes.
while the DNN model recorded a recall of 0.90. These results
indicate reduced sensitivity to minority class detection due to the
dataset’s class imbalance.
449 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
450 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
Fig. 11. XGBoost confusion matrix. Model Accuracy Precision Recall F1-score AUC
LSTM 0.99 0.57 0.53 0.52 0.92
Table VI summarizes the performance of LSTM, DNN, RF,
KNN, and XGBoost on the binary classification task. DNN 0.99 0.10 0.10 0.10 0.50
RF 0.99 0.66 0.62 0.64 0.94
TABLE VI. BINARY CLASSIFICATION PERFORMANCE WITH SMOTE
KNN 0.99 0.61 0.58 0.59 0.87
Model Accuracy Precision Recall F1-score AUC
XGBoost 0.99 0.66 0.60 0.62 0.98
LSTM 0.99 0.94 0.99 0.97 0.99
DNN 0.99 0.94 0.99 0.96 0.99 TABLE VIII. MULTI-CLASS CLASSIFICATION MACRO-AVERAGED SCORES
RF 0.99 0.95 0.99 0.97 0.99 Model Accuracy Precision Recall F1-score AUC
KNN 0.99 0.95 0.99 0.97 0.99 LSTM 0.99 0.62 0.56 0.56 0.99
XGBoost 0.99 0.95 0.99 0.97 0.99 DNN 0.99 0.66 0.57 0.59 0.99
Unlike binary classification, the multi-class classification KNN 0.99 0.69 0.66 0.63 0.89
task suffered from noticeable performance degradation in the XGBoost 0.99 0.73 0.80 0.71 0.99
absence of SMOTE, especially in models like DNN, which
recorded extremely low precision, recall, and F1-score (all =
0.10) despite an overall accuracy of 0.99. This illustrates that
accuracy alone is misleading under class imbalance.
Similarly, LSTM showed moderate metrics (F1 = 0.52),
while Random Forest and XGBoost performed relatively better
(F1 = 0.64 and 0.62 respectively). AUC scores also reflected this
trend—DNN had a poor AUC of 0.50, while XGBoost reached
0.98. These results demonstrate the limitations of models when
trained on highly imbalanced data and reinforce the need for
resampling methods like SMOTE to achieve fair multi-class
performance across all attack types.
Table VII summarizes the performance of LSTM, DNN, RF,
KNN, and XGBoost on the multi-class classification task before
applying SMOTE.
Table VIII details the multi-class classification performance
across the same set of models after SMOTE.
Fig. 12. XGboost confusion matrix in multi-classification.
451 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
Fig. 14. DNN confusion matrix in multi-classification. TABLE IX. PREDICTION TIME FOR EACH CLASSIFIER
The confusion matrix of KNN (Fig. 15) shows good Avg. Time per 1000
Model Task Total Time (s)
Records (s)
effectiveness, better than LSTM and DNN, but still less than
LSTM Binary 25 0.3575
Xgboost.
DNN Binary 20 0.0700
Random Forest delivers a compact and efficient confusion
matrix, excelling at distinguishing between multiple attack RF Binary 4.519 0.0076
types, especially frequent ones, while showing some overlap in KNN Binary 73.4142 0.1232
less-represented classes as shown in Fig. 16. XGBoost Binary 14.323 0.0240
D. Inference Time Evaluation for Real-Time Applicability LSTM Multi-class 22.8 0.07
In addition to classification performance, prediction time is DNN Multi-class 20.5489 0.0690
a critical consideration for real-world deployment, particularly
RF Multi-class 5.0694 0.0128
in systems requiring real-time or near-real-time responses. Table
IX presents both the total and average prediction times (per KNN Multi-class 39.0577 0.0983
1,000 records) for each model across binary and multi-class XGBoost Multi-class 26.7887 0.0449
classification tasks, providing insight into their computational
efficiency.
452 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
Random Forest exhibited the fastest prediction times in both and accuracy exceeding 99% in binary classification. These
binary and multi-class tasks, making it highly suitable for real- models also maintained robustness in multi-class scenarios,
time applications. Random Forest also demonstrated strong achieving macro F1-scores of up to 0.71.
efficiency, whereas deep learning models, particularly LSTM
and KNN, had the longest processing times. In contrast, the recent work by Samantaray et al. [9], which
employed traditional ML algorithms on the same dataset,
V. DISCUSSION reported significantly lower macro F1-scores—only 0.26 with
Logistic Regression and 0.17 with Random Forest—despite
This study presents a comprehensive evaluation of multiple using MaxAbsScaler for feature scaling. Although their
machine learning (ML) and deep learning (DL) classifiers for approach achieved relatively high overall accuracy (up to 94%)
both binary and multi-class network intrusion detection using in multi-class classification, the low macro-averaged metrics
the NF-UNSW-NB15 dataset. The results demonstrate that the reflect poor generalization across minority classes, indicating
proposed models—particularly XGBoost and Random Forest—
that class imbalance was not sufficiently addressed.
achieved superior performance, with macro-averaged F1-scores
Study Model Dataset Type Accuracy Macro Precision Macro Recall Macro F1-Score
This Work RF NF-UNSW-NB15-v2 Binary 0.99 0.95 0.99 0.97
This Work XGBoost NF-UNSW-NB15-v2 Multi-class 0.99 0.73 0.80 0.71
Kasongo and Sun [4] XGBoost NF-UNSW-NB15 Binary 0.91 0.80 0.98 0.88
Samantaray et al. [9] RF NF-UNSW-NB15 Multi-class 0.90 0.23 0.20 0.17
Samantaray et al. [9] KNN NF-UNSW-NB15 Multi-class 0.93 0.29 0.31 0.26
Sayed et al. [10] IoTCNN NF-UNSW-NB15-v2 Multi-class ~0.99 ~0.42 ~0.63 ~0.44
Sharma et al. [33] RF UNSW‑NB15 Binary 0.87 0.90 0.86 0.86
Similarly, the CNN-based models proposed by Sayed et al. on the “NF-UNSW-NB15-v2” dataset. The experiments
[10], namely IoTCNN and MyCNN, demonstrated limited covered both binary (normal vs attack) and nine-class attack
macro-level performance. For example, the IoTCNN model identification tasks, using a unified hyper-parameter budget to
produced low precision and F1-scores in most attack categories, ensure fair comparison.
including F1 = 0.14 for Analysis and 0.13 for DoS, despite
exhibiting high overall accuracy. These results suggest that Results underscore the strength of ensemble trees for tabular
while convolutional models may effectively capture local network-flow data: XGBoost and Random Forest achieved high
patterns, they often struggle with inter-class variance and metrics (≈ 0.9960 for accuracy, precision, recall, F1, and AUC)
generalization without advanced preprocessing or data in binary detection, while XGBoost retained a competitive
augmentation strategies. macro F1-score (0.71) and a balanced confusion matrix in multi-
class testing. Deep models matched overall accuracy but lagged
In addition to Samantaray et al. [9] and Sayed et al. [10], we in macro scores, indicating residual sensitivity to minority
include the study by Sharma et al. [33], which evaluates classes. Crucially,RF and XGBoost’s inference latency—on the
ensemble methods on UNSW-NB15 using a binary setting. order of milliseconds per thousand flows—demonstrates that
Their best model (Random Forest) achieves Accuracy = 0.87, top-tier accuracy can coexist with real-time throughput, making
Macro Precision = 0.90, Macro Recall = 0.86, and Macro the approach deployable in production networks.
F1 = 0.86, whereas our binary IDS on NF-UNSW-NB15-v2
attains Accuracy ≈ 0.99 and Macro F1 ≈ 0.97. Thus, our Although the pipeline raises the state of the art for this
approach improves binary macro-level performance by ≈ 11 dataset, two limitations remain: extremely rare classes such as
points in F1 while also raising accuracy by ≈ 12 percentage Worms and Analysis still risk misclassification despite SMOTE,
points, reinforcing that the proposed SMOTE + PCA + diverse and features were restricted to NetFlow attributes. Future work
should explore cost-sensitive or generative resampling, integrate
ML/DL pipeline generalizes better under class imbalance than
strong ensemble baselines. payload-level and temporal-correlation features, and test hybrid
architectures (e.g., LSTM embeddings feeding XGBoost) under
Overall, our findings highlight the effectiveness of ensemble online-learning and edge-deployment constraints. Overall, the
models—such as XGBoost and Random Forest—in capturing study provides a reproducible blueprint and a strong baseline for
complex feature relationships and addressing class imbalance. A practitioners seeking accurate, low-latency, and resource-
comparative summary of results is provided in Table X. efficient intrusion detection in modern networked environments.
VI. CONCLUSION ACKNOWLEDGMENT
This work developed and empirically validated an end-to- The authors extend their appreciation to the Deanship of
end intrusion-detection pipeline that couples rigorous Research and Graduate Studies at King Khalid University for
preprocessing (StandardScaler normalization, SMOTE funding this work through Large Research Project under grant
oversampling, and PCA dimensionality reduction) with five number RGP2/318/46.
classifiers (XGBoost, RF, KNN, DNN, and LSTM) evaluated
453 | P a g e
[Link]
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 16, No. 8, 2025
454 | P a g e
[Link]