scieee AI-readable full text Open interactive document viewer

Machine Learning for malware detection and classification

Bruna Moralejo, Lourdes

Abstract

Malware is any intrusive program that exploits system vulnerabilities on a computing system. A malware infection can be disastrous for any organization. It can cripple networks and systems, as well as destroy, delete, corrupt, or exfiltrate sensitive data. In this thesis we explore how machine learning can detect and classify malware threats to prevent further damage in a network. Specifically, we use Naive Bayes, K-Nearest Neighbours, Decision Tree, Random Forest and Support Vector Machine algorithms, determining the precision, accuracy and recall averages for 100 different random states, as well as the variance of each one of these averages. We will use two datasets: the CIC-Evasive-PDFMal2022 dataset (which consists of 10025 records and 28 numerical features) and the CIC-MalMem-2022 dataset (which consists of 58596 records and 55 numerical features). For malware classification, we will only use the second one because the first one is not labeled with the malware type.

Full text

Machine Learning for malware detection and classification Master Thesis submitted to the Faculty of the Escola T`ecnica d’Enginyeria de Telecomunicaci´o de Barcelona Universitat Polit`ecnica de Catalunya by Lourdes Bruna Moralejo In partial fulfillment of the requirements for the master in Cybersecurity Advisor: Olga Le´on Abarca Barcelona, 26/06/2023 Contents List of Figures 3 List of Tables 5 1 Introduction 8 1.1 GanttDiagram ................................. 9 2 State of the art 10 2.1 NaiveBayes................................... 11 2.2 K-NearestNeighbours ............................. 12 2.3 DecisionTree .................................. 14 2.4 RandomForest ................................. 15 2.5 Support Vector Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3 Methodology 18 4 Results 22 4.1 Malware detection with CIC-Evasive-PDFMal2022 dataset . . . . . . . . . 22 4.1.1 NaiveBayes............................... 22 4.1.2 K-Nearest Neighbours . . . . . . . . . . . . . . . . . . . . . . . . . 24 4.1.3 DecisionTree .............................. 30 4.1.4 RandomForest ............................. 33 4.1.5 Support Vector Machine . . . . . . . . . . . . . . . . . . . . . . . . 34 4.1.6 Summary ................................ 36 4.2 Malware detection with CIC-MalMem-2022 dataset . . . . . . . . . . . . . 37 4.2.1 Bernoulli Naive Bayes . . . . . . . . . . . . . . . . . . . . . . . . . 37 4.2.2 K-Nearest Neighbours (Hamming Distance) . . . . . . . . . . . . . 37 4.2.3 DecisionTree .............................. 38 4.2.4 RandomForest ............................. 39 4.2.5 Support Vector Machine . . . . . . . . . . . . . . . . . . . . . . . . 40 4.2.6 Summary ................................ 40 4.3 Malware classification with CIC-MalMem-2022 dataset . . . . . . . . . . . 41 4.3.1 NaiveBayes............................... 41 4.3.2 K-Nearest Neighbours . . . . . . . . . . . . . . . . . . . . . . . . . 44 4.3.3 DecisionTree .............................. 45 4.3.4 RandomForest ............................. 48 4.3.5 Support Vector Machine . . . . . . . . . . . . . . . . . . . . . . . . 49 4.3.6 Summary ................................ 49 5 Conclusions and future development 50 Glossary 52 References 53 2 List of Figures 1 Project’sGanttdiagram ............................ 9 2 Artificial Intelligence scheme1.......................... 10 3 Traditional Programming vs Machine learning2. ............... 10 4 Machine learning classification scheme3..................... 11 5 K-Nearest Neighbour example. . . . . . . . . . . . . . . . . . . . . . . . . . 12 6 Example of Decision Tree scheme for animal classification4.......... 14 7 Visualization of a Random Forest Model making a Prediction. . . . . . . . 15 8 Conceptual overview of Support Vector Machine. . . . . . . . . . . . . . . 16 9 Conceptual overview of Radial Basis Function5. ............... 16 10 Example of how random state works6...................... 20 11 TheConfusionMatrix.............................. 20 12 Averages and variances of precision, recall and accuracy (in relation with the test size) using a Gaussian Naive Bayes algorithm (CIC-Evasive-PDFMal2022 dataset)...................................... 23 13 Averages and variances of precision, recall and accuracy (as a function of the test size) using a Bernoulli Naive Bayes algorithm (CIC-Evasive- PDFMal2022dataset). ............................. 23 14 Precision, recall and accuracy calculated for different K values and test size = 0.15 (left), 0.55 (right), using the Euclidean distance (CIC-Evasive- PDFMal2022dataset). ............................. 24 15 Accuracy average calculated for lower test sizes and Ks, using the Euclidean distance (CIC-Evasive-PDFMal2022 dataset). . . . . . . . . . . . . . . . . 25 16 KNN (Euclidean distance) results for 1 <random state <100, 1% <test size <50% and K = 3 (CIC-Evasive-PDFMal2022 dataset). . . . . . . . . 25 17 Accuracy average calculated for lower test sizes and Ks, using the Manhattan distance (CIC-Evasive-PDFMal2022 dataset). . . . . . . . . . . . . . . 26 18 KNN (Manhattan distance) results for 1 <random state <100, 1% <test size <50% and K = 3 (CIC-Evasive-PDFMal2022 dataset). . . . . . . . . 26 19 Accuracy average calculated for lower test sizes and Ks, using the Chebychev distance (CIC-Evasive-PDFMal2022 dataset). . . . . . . . . . . . . . 27 20 KNN (Chebychev distance) results for 1 <random state <100, 1% <test size <50% and K = 1 (CIC-Evasive-PDFMal2022 dataset). . . . . . . . . 27 21 Accuracy average calculated for lower test sizes and Ks, using the Hamming distance (CIC-Evasive-PDFMal2022 dataset). . . . . . . . . . . . . . . . . 28 22 KNN (Hamming distance) results for 1 <random state <100, 1% <test size <50% and K = 3 (CIC-Evasive-PDFMal2022 dataset). . . . . . . . . 28 23 Accuracy average calculated for lower test sizes and Ks, using the Cosine distance (CIC-Evasive-PDFMal2022 dataset). . . . . . . . . . . . . . . . . 29 24 KNN (Cosine distance) results for 1 <random state <100, 1% <test size <50% and K = 5 (CIC-Evasive-PDFMal2022 dataset). . . . . . . . . . . . 29 25 Finding the maximum depth of the tree and the test size values for malware detection (CIC-Evasive-PDFMal2022 dataset). . . . . . . . . . . . . . . . . 31 3 26 Decision tree results for 1 <random state <100, 1% <test size <60% and max depth = 11 (malware detection with CIC-Evasive-PDFMal2022 dataset)...................................... 31 27 Best accuracy obtained with “GridSearchCV” for each test size value( 1 < max depth <100) with CIC-Evasive-PDFMal2022 dataset. . . . . . . . . . 32 28 Accuracy average (left) and variance (right) obtained for different max depth and test size = 0.15 (malware detection with CIC-Evasive-PDFMal2022 dataset)...................................... 32 29 Random Forest results (obtained with max depth = 11 and test size = 0.15) with CIC-Evasive-PDFMal2022 dataset. . . . . . . . . . . . . . . . . 33 30 Accuracy calculated for different C values and test size = 0.23 (left), 0.33 (right)....................................... 34 31 Precision, recall and accuracy average calculated for lower test sizes and C =185....................................... 34 32 Precision, recall and accuracy calculated for different gamma values and test size = 0.05 (left), 0.14 (right). . . . . . . . . . . . . . . . . . . . . . . 35 33 Averages and variances of precision, recall and accuracy (in relation with the test size) using a Bernoulli Naive Bayes algorithm (CIC-MalMem-2022 dataset)...................................... 37 34 KNN (Hamming distance) results for 1 <random state <100, 1% < test size <50% and K = 3 (CIC-MalMem-2022 dataset). . . . . . . . . . . 37 35 KNN (Hamming distance) results for 1 <random state <100, 1% < test size <50% and K = 1 (CIC-MalMem-2022 dataset). . . . . . . . . . . 38 36 Decision tree results for 1 <random state <100, 1% <test size <60% and max depth = 11 (malware detection with CIC-MalMem-2022 dataset). 38 37 Accuracy average (left) and variance (right) obtained for different max depth and test size = 0.17 (malware detection with CIC-MalMem-2022 dataset). 39 38 Random Forest results (obtained with max depth = 7 and test size = 0.17) with CIC-MalMem-2022 dataset. . . . . . . . . . . . . . . . . . . . . . . . 39 39 SVM results (obtained with C = 11, gamma = 0.03 and test size = 0.15) with CIC-MalMem-2022 dataset. . . . . . . . . . . . . . . . . . . . . . . . 40 40 Accuracy average (left) and variance average (right) obtained for different test sizes with Multinomial Naive Bayes. . . . . . . . . . . . . . . . . . . . 41 41 Multinomial Naive Bayes confusion matrix obtained for test size = 0.26. . . 41 42 Accuracy average (left) and variance average (right) obtained for different test sizes with Bernoulli Naive Bayes. . . . . . . . . . . . . . . . . . . . . . 42 43 Bernoulli Naive Bayes confusion matrix obtained for test size = 0.33. . . . 42 44 Bernoulli Naive Bayes confusion matrix obtained for test size = 0.33, undersamplingthedataset............................. 43 45 Bernoulli Naive Bayes confusion matrix obtained for test size = 0.33, oversamplingthedataset............................... 43 46 Accuracy calculated for lower test sizes and Ks, using the Hamming distance (random state = 123). . . . . . . . . . . . . . . . . . . . . . . . . . . 44 47 KNN (Hamming distance) results for 1 <random state <100, 1% <test size <50%andK=1.............................. 44 4 48 KNN confusion matrix obtained for test size = 0.10 and K = 1, using the Hammingdistance................................ 45 49 Finding the maximum depth of the tree and the test size values for malware classification. .................................. 45 50 Decision tree results for 1 <random state <100, 1% <test size <60% and max depth = 11 (malware classification). . . . . . . . . . . . . . . . . 46 51 Decision Tree confusion matrix obtained for test size = 0.18 and max depth =20........................................ 46 52 Best accuracy obtained with “GridSearchCV” for each test size value ( 1 <max depth <100)............................... 47 53 Accuracy average (left) and variance (right) obtained for different max depth and test size = 0.15 (malware classification). . . . . . . . . . . . . . . . . . 47 54 Random Forest results (obtained with max depth = 20 and test size = 0.18). 48 55 Random Forest confusion matrix obtained using 25 trees. . . . . . . . . . . 48 56 SVM confusion matrix obtained using C = 125 and gamma = 0.07. . . . . 49 List of Tables 1 CIC-Evasive-PDFMal2022 most relevant features list. . . . . . . . . . . . . 18 2 CIC-MalMem-2022 most relevant features list. . . . . . . . . . . . . . . . . 19 3 Hyperparameters that need to be configured. . . . . . . . . . . . . . . . . . 22 4 Results obtained using the different distances in KNN. . . . . . . . . . . . 30 5 Computation times for different kernel functions. . . . . . . . . . . . . . . 34 6 Computation time as a function of the numbers of features. . . . . . . . . . 36 7 Detection results obtained using different algorithms with the CIC-Evasive- PDFMal2022dataset............................... 36 8 Detection results obtained using different algorithms with the CIC-MalMem- 2022dataset. .................................. 40 9 Classification results obtained using different algorithms with the CIC- MalMem-2022dataset.............................. 49 5 Revision history and approval record Revision Date Purpose 0 14/02/2023 Document creation 1 02/03/2023 Document revision 2 05/04/2023 Document revision 3 20/06/2023 Document revision 4 26/06/2023 Final document DOCUMENT DISTRIBUTION LIST Name e-mail Lourdes Bruna Moralejo [email protected] Olga Le´on Abarca [email protected] Written by: Reviewed and approved by: Date 25/06/2023 Date 26/06/2023 Name Lourdes Bruna Moralejo Name Olga Le´on Abarca Position Project Author Position Project Supervisor 6 Abstract Malware is any intrusive program that exploits system vulnerabilities on a computing system. A malware infection can be disastrous for any organization. It can cripple networks and systems, as well as destroy, delete, corrupt, or exfiltrate sensitive data. In this thesis we explore how machine learning can detect and classify malware threats to prevent further damage in a network. Specifically, we use Naive Bayes, K-Nearest Neighbours, Decision Tree, Random Forest and Support Vector Machine algorithms, determining the precision, accuracy and recall averages for 100 different random states, as well as the variance of each one of these averages. We will use two datasets: the CIC-Evasive-PDFMal2022 dataset (which consists of 10025 records and 28 numerical features) and the CIC-MalMem- 2022 dataset (which consists of 58596 records and 55 numerical features). For malware classification, we will only use the second one because the first one is not labeled with the malware type. 7 1 Introduction Nowadays, cyberattacks have become a pervasive and persistent threat that can target a wide range of victims from individual users to enterprises or even governments. These malicious activities, carried out by cybercriminals, aim to gain unauthorized access, disrupt operations, steal sensitive data, or cause damage to computer systems, networks, or devices. Some of the most common cyberattacks are [1] [2]: – Web Application attacks: vulnerabilities in web applications or websites to gain unauthorized access, steal data, or disrupt operations. This includes Structured Query Language (SQL) injection, Cross-Site Scripting (XSS) and Cross-Site Request Forgery (CSRF). – Man-in-the-Middle attacks: intercepting communications between two parties to eavesdrop, modify, or inject malicious content. – Denial of Service (DoS) attacks: disrupt or disable a computer system, network, or service by overwhelming it with excessive traffic or other means, making it unavailable or unresponsive to legitimate users. – Social Engineering attacks: manipulate individuals to reveal sensitive information or perform actions that can compromise security. – Password cracking attacks: attempting to guess passwords to gain unauthorized access to user accounts or systems. – Malware attacks: malicious software designed to harm or exploit computer systems, networks or devices. Some examples are viruses, worms, Trojans, ransomware, and spyware. We will focus on detecting and classifying malware attacks, which are one of the most common types of cyberattacks and can cause significant harm to individuals, organizations, and even entire networks. However, with the increasing sophistication and diversity of malware, traditional signature-based detection methods are often insufficient. To address these challenges, machine learning has emerged as a promising solution, leveraging its ability to analyze data, learn patterns, and adapt to new threats for more effective detection and mitigation of malware [3]. The main goal of this project is to detect malware using different machine learning algorithms. This includes the research of a dataset with malware records, as well as the data preprocessing and the study of the algorithms that could be applied to the specific dataset. Specifically, we will use supervised machine learning algorithms. Finally, we will train the algorithms, selecting the appropriate hyperparameters in order to obtain the best results, and we will evaluate and compare the models using metrics such as precision, recall and accuracy. Thus, the project does not include capturing network traffic for generating the dataset. 8 In addition, the project will initially focus on building machine learning models for malware detection. This means that the model will only predict if a record is malware or not. Once we have this, we will also build malware classification models. In other words, the model will categorize malware into different types such as ransomware, spyware or Trojans. In short, the objectives of this project are: – Understand how the main machine learning algorithms work. – Tun the algorithms selecting the appropriate hyperparameters. – Compare the results obtained for the different algorithms. 1.1 Gantt Diagram The project is divided in the activities shown in figure 1. Phases of the Project 2023 January February March April May June Planning Detection NB KNN DT RF SVM Classification NB KNN DT RF SVM Documentation Figure 1: Gantt diagram of the project. – Planning. It includes the research of the datasets and the study of the machine learning algorithms, as well as the project planification. Thus, the state of the art research is also included. – Detection. Malware detection using the next machine learning algorithms: Naive Bayes, K-Nearest Neighbours, Decision Tree, Random Forest and Support Vector Machine. We will apply these algorithms to two different datasets. – Classification. Malware classification using the same algorithms as before. We will apply these algorithms to only one dataset because the other one is not labeled with malware type. – Documentation. The thesis writing. 9 2.5 Support Vector Machine Support Vector Machine (SVM) [20] aim at finding decision boundaries that separate observations with differing class memberships. They can handle highly non-linear problems using a kernel trick, which implicitly maps the input vectors to higher-dimensional feature spaces. This transformation rearranges the dataset in such a way that it is then linearly solvable (figure 8). Figure 8: Conceptual overview of Support Vector Machine. In this way, the data points that define the position and the margin of the hyperplane are called support vectors. Thus, basically we want to find the hyperplane with the best margin. There are different types of kernel functions. Some common kernels are linear, polynomial, Radial Basis Function (RBF) and sigmoid. The most preferred kind of kernel function is RBF [21], that is the kernel that we will use. It is a real-valued function whose value is dependent on the distance between the input and some fixed point (figure 9). Figure 9: Conceptual overview of Radial Basis Function11. 11Image taken from [22]. 16 Finally, in SVM, the main goals are [23]: – Setting a larger margin, which is the distance of decision boundary to classes (or support vectors). – Lowering misclassification rate(how much a model misqualifies a data). However, if we increase margin, we will end up getting a high misclassfication rate. On the other hand, if we decrease a margin, we will end up getting a lower misclassification rate [24]. That is why we will have to define a regularization hyperparameter (called C) that controls the trade-off between the classification of training points accurately and a smooth decision boundary [26] [25]. In addition, we have also to decide the gamma value, that defines how far the influence of a single training example reaches. This means that high Gamma will consider only points close to the plausible hyperplane and low Gamma will consider points at greater distance. 17 3 Methodology We are going to build a Machine Learning model in Python. Therefore, we will use Scikitlearn [27], a library that provides a wide range of machine learning algorithms. In addition, we will use Matplotlib for plotting the obtained results, as well as NumPy for some mathematical operations. The steps to follow are [5] [28]: – Gathering Data: identify various data sources and collect the required dataset. In our case, we will use two datasets [29] (that will be read using the function read csv from Pandas library): – CIC-Evasive-PDFMal2022 [30]: an evasive PDF dataset which consists of 10025 records with 5533 malicious and 4466 benign records. Since this dataset only contains labels indicating whether each record is benign or malicious, we will only use it for malware detection. Each PDF has 28 numerical features. The most relevant are shown in table 1. Feature Type Feature List Feature Description General pdfsize PDF size title characters Title characters isEncrypted Whether the PDF document is password protected or not metadata size Metadata can be exploited for embedding hidden contents pages Number of pages images Number of images in the document obj Number of total objects inside the PDF embedded files Number of embedded files inside the document Structural stream Number of streams (sequences of binary data) xref Number of Xref tables ObjStm Number of stream objects (streams that contain other objects) JS Number of objects containing Javascript code AA Number of AA keywords (specific actions upon an event) OpenAction Number of OpenAction keywords (specific actions upon opening the PDF file) launch Number of Launch keywords Acroform Number of Acroform tags (form fields that support scripting technologies) XFA Number of XFA keywords (XML Form Architecture) JBIG2Decode Presence of JBig2Decode filter Colors Different colors used in the PDF RichMedia Number of RichMedia keywords (embedded media and flash files) Table 1: CIC-Evasive-PDFMal2022 most relevant features list. 18 – CIC-MalMem-2022 [31]: an obfuscated malware dataset to represent as close to a real-world situation as possible using malware that is prevalent in the real world. This dataset consists of 58596 records, with 29298 malicious and 29298 benign records. Specifically, 9791 records correspond to ransomware, 10020 spyware and 9487 trojan. Since this dataset is labeled by malware category, we will use it for malware detection and classification. Each record has 55 numerical features. The most relevant are shown in table 2. Feature Type Feature List Feature Description Malfind commitCharge Total number of Commit Charges protection Total number of protection uniqueInjections Total number of unique injections Ldrmodule avgMissingFromLoad Average amount of modules missing from the load list avgMissingFromInit Average amount of modules missing from the initialization list avgMissingFromMem Average amount of modules missing from memory Handles port Total number of port handles file Total number of file handles event Total number of event handles desktop Total number of desktop handles key Total number of key handles thread Total number of thread handles directory Total number of directory handles semaphore Total number of semaphore handles timer Total number of timer handles section Total number of section handles mutant Total number of mutant handles Process View pslist Average false ratio of the process list psscan Average false ratio of the process scan thrdproc Average false ratio of the third process pspcid Average false ratio of the process id session Average false ratio of the session deskthrd Average false ratio of the deskthrd Apihooks nhooks Total number of apihooks nhookInLine Total number of in line apihooks nhooksInUsermode Total number of apihooks in user mode Table 2: CIC-MalMem-2022 most relevant features list. – Data Preprocessing: analysis of the data for missing values, duplicate and invalid data. – Data standarizing: for many machine learning algorithms, performance is highly sensitive to the relative scale of features. For that reason, if we want to optimize the model performance, it is important to standardize features between -1 and 1. 19 – Data split: we also need to split the dataset into random training and test subsets. We will use the “train test split” function from Sklearn. In general, for smaller datasets we would need 70% of the dataset for training (and 30% for test), while for bigger datasets we would need 80% or 90% for training (and 20% or 10% for test) [32]. However, this relation would vary for each specific dataset. We will also need to define the random state, that controls the shuffling applied to the data before applying the split. In other words, the data contained in training and test subsets will depend on the chosen random state (figure 10). Thus, fixing a random state, the model will produce the same results across different executions. Figure 10: Example of how random state works12. – Training the model: we use the processed training subset to train the model using the machine learning algorithms explained in section 2. – Evaluating and selecting the model: we use the trained model to predict the values of the test subset. So, we need to configure the training and test sizes (as well as other specific hyperparameters of every algorithm) in order to obtain the best results. We could also find the hyperparametes using “GridSearchCV”, an Sklearn function that carries out an exhaustive search over specified parameter values (in our case, we will use the accuracy) for the model. In other words, “GridSearchCV” tries all the combinations of the values passed in the dictionary and evaluates the model for each combination using the Cross-Validation method [34] [35], a technique for evaluating machine learning models by training them on subsets of the available input data and evaluating them on the complementary subset of the data. In order to determine which are the best results, we could use a confusion matrix [36], a table that evaluates the performance of a classification algorithm (figure 11). Figure 11: The Confusion Matrix. 12Image taken from [33]. 20 Where: – True Positive (TP) values: the predicted value is positive and it is true (the real value is also positive). – True Negative (TN) values: the predicted value is negative and it is true (the real value is also negative). – False Positive (FP) values: the predicted value is positive but it is false (the real value is negative). – False Negative (FN) values: the predicted value is negative but it is false (the real value is positive). Then, we can check the next metrics: – Precision (eq. 11): how close measurements are to each other. In other words, how well the attacks reported have been detected. TP TP +FP (11) – Recall (eq. 12): how many times the model was able to detect a specific category. TP TP +FN (12) – Accuracy (eq. 13): how close a measurement is to the true value. In other words, how many values from the total are predicted well. TP +TN TP +TN +FP +FN (13) – Variance: the average degree to which each point differs from the mean. We will use a NumPy function called “var”. In order to calculate those metrics, we could use the Sklearn function called “confusion matrix”. However, Sklearn has some functions that directly compute them: “precision score”, “recall score” and “accuracy score”. Therefore, we will use those functions. Finally, we will determine the precision, accuracy and recall for a 100 different random states and we will calculate the average of each one. We will also calculate the variance of each one of these averages. The code developed can be found at GitHub [37]. 21 4 Results In this section we will explain the results obtained for the different algorithms introduced before. Firstly, we will focus on malware detection and, then, on malware classification. On the other hand, as we explained in the methodology section, for all the algorithms we need to find the optimum values of training and test subsets. Nevertheless, there are also some specific hyperparameters of each algorithm that we need to configure (table 3). Algorithm Hyperparameters Meaning KNN K Number of neighbors metric Metric to use for distance computation Decision Tree max depth Depth of the tree criterion Function to measure the quality of a split splitter Strategy used to choose the split at each node min samples split Minimum number of samples required to split an internal node min samples leaf Minimum number of samples required to be at a leaf node Random Forest n estimators Number of trees SVM kernel Kernel type C Regularization hyperparameter gamma Influence of data points Table 3: Hyperparameters that need to be configured. In Random Forest we only include the n estimators hyperparameter because the other hyperparameters are the same that in Decision Tree. 4.1 Malware detection with CIC-Evasive-PDFMal2022 dataset In order to determine which algorithm is better for malware detection, we need to evaluate the precision average (as well as the recall and accuracy averages) and the variances for different random states and test sizes. 4.1.1 Naive Bayes A first approach can be carried out using a Gaussian Naive Bayes algorithm, setting a random state = 123 and changing the test data size. The results are: highest precision [’test size: 0.26’, ’precision: 0.951’, ’recall: 0.321’, ’accuracy: 0.615’] lowest precision [’test size: 0.06’, ’precision: 0.897’, ’recall: 0.326’, ’accuracy: 0.618’] highest recall [’test size: 0.01’, ’precision: 0.913’, ’recall: 0.389’, ’accuracy: 0.650’] lowest recall [’test size: 0.13’, ’precision: 0.929’, ’recall: 0.297’, ’accuracy: 0.607’] highest accuracy [’test size: 0.01’, ’precision: 0.913’, ’recall: 0.389’, ’accuracy: 0.650’] lowest accuracy [’test size: 0.43’, ’precision: 0.932’, ’recall: 0.310’, ’accuracy: 0.603’] As we can see, the test size values were changed between 1% and 44% of the total dataset size. This value can not be bigger because the model is not able to make a prediction in situations where the categorical variable has a category that was not observed in the 22 training data set and assigns a 0 (zero) probability to it [10]. In other words, for a test data size bigger than 44% sometimes (depending on the random state) the model predicts that all the values are 0 (malware not detected). Hence, precision can not be calculated (true positives = false positives = 0). However, these results are not representative because we are not changing the random state. For that reason, we will determine the precision, accuracy and recall for 100 different random states (as we explained in the Methodology chapter). In figure 12, the averages of those 100 random states are represented in a graph. Figure 12: Averages and variances of precision, recall and accuracy (in relation with the test size) using a Gaussian Naive Bayes algorithm (CIC-Evasive-PDFMal2022 dataset). As we can see, when we increase the test size, we obtain better precision, recall and accuracy results. However, the recall and accuracy variances also increases. This means that, for a higher test size, recall and accuracy change a lot depending on the chosen random state. In other words, since we are using a lower number of training records, the model depends a lot on those records. In addition, the recall and accuracy values obtained are too low (around 45% and 65%, respectively). This could be due to the fact that we are assuming that data follows a normal distribution, but it does not because it has two classes (malware and benign records). For this reason, we will use a Bernoulli Naive Bayes algorithm (figure 13), that should be better to predict if a file is malware or not (boolean values). Figure 13: Averages and variances of precision, recall and accuracy (as a function of the test size) using a Bernoulli Naive Bayes algorithm (CIC-Evasive-PDFMal2022 dataset). In this case, the precision, recall and accuracy values are around 90% and the variance values decrease with higher test size values. Thus, we should choose a high test size, that could be 40%, for example. 23 4.1.2 K-Nearest Neighbours In this section, we will find the hyperparameters that give best results in KNN using different distance metrics. After that, we will compare those results to find which metric fits better in our specific case (malware detection and classification). Theoretically, we should obtain the best results with the Hamming distance because it is the most common metric used to measure distances between categorical variables, as we explained in section 2.2. Euclidean distance Firstly, we need to find the optimal value for K. A first approach could be to change the test size percentage (in increments of 10%) and the K values, using a random state = 123. In figure 14 an example is shown. Figure 14: Precision, recall and accuracy calculated for different K values and test size = 0.15 (left), 0.55 (right), using the Euclidean distance (CIC-Evasive-PDFMal2022 dataset). As we can see, for K >10 the values decrease significantly. In addition, with a test data size higher than 50% the recall and accuracy also decrease. This will occur for all the different distances used. Thus, in all the cases, we will focus on K values lower than 10 and test size values lower than 50%. In figure 15 we can see the results obtained using the Euclidean distance. In this case, we obtain the best results for K = 1, 3. We choose K = 3 because, with K = 1, the system usually is more sensitive to all sort of distortions like noise, outliers or mislabelling of data [11]. After that, we can evaluate the precision, recall and accuracy averages for different random states, as well as the variances. We will focus on test size values lower than 50%, since for higher values the accuracy average decreases (figure 15). Results are shown in figure 16. 24 Figure 15: Accuracy average calculated for lower test sizes and Ks, using the Euclidean distance (CIC-Evasive-PDFMal2022 dataset). Figure 16: KNN (Euclidean distance) results for 1 <random state <100, 1% <test size <50% and K = 3 (CIC-Evasive-PDFMal2022 dataset). We choose a test size of 0.09 because it is when we obtain better values of precision, recall and accuracy averages in relation with the variance. 25 Thus, we choose max depth = 11 and test size = 0.15, that give the precision, recall, accuracy and variances (for different random states) shown in the same figure. We could also find the depth of the tree using “GridSearchCV”. Specifically, for a depth range between 1 and 100 and test size between 0.01 and 0.50, we obtain the results shown in figure 27. Figure 27: Best accuracy obtained with “GridSearchCV” for each test size value( 1 < max depth <100) with CIC-Evasive-PDFMal2022 dataset. As we can see, for test size = 0.12, we obtain an accuracy of 0.99, approximately. We can also calculate the accuracy variance, that is around 8.97e-06. Those values are obtained for a max depth = 71. We can observe that this depth is not the same that the one obtained before because we are not considering the accuracy variance (for higher values of max depth the accuracy increases but the variance decreases), as we can see in figure 28. In addition, “GridSearchCV” uses different random states that the ones we used. Figure 28: Accuracy average (left) and variance (right) obtained for different max depth and test size = 0.15 (malware detection with CIC-Evasive-PDFMal2022 dataset). In short, although with “GridSearchCV” we obtain a better accuracy value, the variance is higher, as well as the max depth (which will result in a higher computation time). Furthermore, accuracy becomes more or less constant for max depth >8. That is why we decided to use the first value obtained (max depth = 11). 32 4.1.4 Random Forest Each individual tree will be trained using the whole training subset [18]. As in the decision tree, we also need to define the random state of the Random Forest algorithm. In order to obtain the best precision, recall and accuracy averages, we need to find the number of trees to use in the algorithm. However, we do not need to find other hyperparameters (like the test subset size or the depth of each tree) because we already have them from the results of the Decision Tree. Figure 29: Random Forest results (obtained with max depth = 11 and test size = 0.15) with CIC-Evasive-PDFMal2022 dataset. In figure 29, we can see that the best precision, recall and accuracy averages are obtained for a high number of trees. However, those averages become more or less constant for 20 trees. Thus, we will choose 20 trees to reduce the computation time as maximum as possible. On the other hand, using “GridSearchCV”, we find that the number of trees should be 48. This number is different from the one that we obtained (20 trees) because, as we can see in figure 29, the accuracy becomes more or less constant for values higher than 20. In addition, “GridSearchCV” uses different random states that the ones we used before. This can result in little differences in the accuracy values, in the way that they are not exactly the same we found previously. 33 4.1.5 Support Vector Machine As we have explained in the State of the art chapter, we are going to use the RBF kernel. In addition, if we compare it with the most common kernels, it has the lowest computation time (table 5). Those times are calculated for only one random state. Kernel Computation time RBF 0.56s Linear 57.24s Polynomial 2.67s Sigmoid 1.93s Table 5: Computation times for different kernel functions. Then, we need to find the C value. A first approach could be to change the test size percentage (in increments of 10%) and the C value (between 1 and 200), using a random state = 123. As we said before, we use the radial basis kernel function. We represent the accuracy in a graph, for every test size value. In figure 30 an example is shown. Figure 30: Accuracy calculated for different C values and test size = 0.23 (left), 0.33 (right). As we can see, the highest values are obtained with a highest C value. Thus, we will choose C = 185, for example. In figure 31 we can see the results obtained. Figure 31: Precision, recall and accuracy average calculated for lower test sizes and C = 185. 34 The final values obtained are: [’C: 128’, ’test size: 0.15’, ’precision: 0.98284’, ’recall: 0.98782’, ’accuracy: 0.98368’] [’precision variance:1.77666e-05’, ’recall variance:1.42986e-05’, ’accuracy variance:8.88299e-06’] After that, we need to find the gamma value (figure 32). Figure 32: Precision, recall and accuracy calculated for different gamma values and test size = 0.05 (left), 0.14 (right). As we can see, the highest values are obtained for lower values of gamma. Thus, we will choose gamma = 0.08, for example. The final values obtained are: [’C: 185’, ’gamma: 0.08’, ’test size: 0.15’, ’precision: 0.98216’, ’recall: 0.98892’, ’accuracy: 0.98390’] [’precision variance:2.03699e-05’, ’recall variance:1.07077e-05’, ’accuracy variance:9.04479e-06’] On the other hand, using “GridSearchCV”, an accuracy of 0.98095 is obtained for C = 125, gamma = 0.07 and test size = 0.15. Again, those little differences in the values could be caused because “GridSearchCV” uses different random states that the ones used before. In short, the results achieved manually are better because more dataset variations are considered. However, “GridSearchCV” is a simpler and faster method to obtain the best hyperparameters, and the results do not decrease significantly. Finally, since in SVM dimensionality is directly related with the number of features, we will try to reduce the number of features to reduce dimensionality. Hence, we could reduce the computation time too. To achieve it, we will use the “SequentialFeatureSelector” function from the Sklearn library. Specifically, we will use a forward approach: it firstly selects the feature that maximizes the average performance of the model and then keeps adding features until the desired number of features is reached or performance does not improve significantly [40][41]. Thus, we tried different numbers of features to see how the computation time changed (table 6). In this table, the column “Features added” is cumulative. This means that each row uses the features of the previous row plus those specified in the same row. 35 Number of features Time Features added 1 135.45s startxref 2 178.77s metadata size 3 120.74s OpenAction 4 90.98s images 6 60.10s pageno, XFA 15 269.03s xref Length, title characters, encrypt, ObjStm, Acroform, JBIG2Decode, RichMedia, launch, EmbeddedFile 20 41.31s pdfsize, xref, trailer, JS, AA 21 36.87s Colors 22 35.59s endobj 25 36.19s isEncrypted, embedded files, obj 27 40.04s stream, endstream 28 40.05s pages Table 6: Computation time as a function of the numbers of features. For lower number of features the computation time increases. This could be because these few selected features would be very close to each other and, therefore, it would be more difficult to find the dimensional plane to separate them. In short, we will use 21 features, that is the lowest number of features that allows to reduce the time. The results obtained with 21 features are: [’C: 125’, ’gamma: 0.07’, ’test size: 0.17’, ’precision: 0.98387’, ’recall: 0.98712’, ’accuracy: 0.98389’] [’precision variance:1.53287e-05’, ’recall variance:1.47045e-05’, ’accuracy variance:8.70867e-06’] As we can see, they do not change significantly with respect to the results obtained with 28 features. 4.1.6 Summary In table 7 we can see a summary of the results obtained using different algorithms, where “Time” is the computation time of each model for a 100 random states. Algorithm Specifications Precision Recall Accuracy Time Naive Bayes Bernoulli 0.87733 0.93287 0.89046 2s KNN Hamming distance, K = 3 0.98722 0.99532 0.99025 65s Decision Tree max depth = 11 0.99191 0.98726 0.98847 4s Random Forest Number of trees = 20 0.99277 0.99385 0.99258 22s SVM C = 125, gamma = 0.07 0.98387 0.98712 0.98389 37s Table 7: Detection results obtained using different algorithms with the CIC-Evasive-PDFMal2022 dataset. In short, the best results are obtained with the Random Forest algorithm. However, the Decision Tree could be a better solution in some applications that require a lower computation time. 36 4.2 Malware detection with CIC-MalMem-2022 dataset For malware detection, a second approach can be carried out with the CIC-MalMem-2022 dataset. Despite this dataset contains different type of records (executable files) and, therefore, different features, we will use it to see how the hyperparameters vary when the dataset is changed. In this way, firstly we will employ identical hyperparameters as those used for the CIC-Evasive-PDFMal2022 dataset. Then, a thorough search will be done to identify the optimal hyperparameters for the second dataset, following the same processes as for the CIC-Evasive-PDFMal2022 dataset. 4.2.1 Bernoulli Naive Bayes In figure 33, we can see that, as for CIC-Evasive-PDFMal2022 dataset, the variance values decrease with higher test size values. Thus, we should choose a high test size, that could be 40%, for example. Figure 33: Averages and variances of precision, recall and accuracy (in relation with the test size) using a Bernoulli Naive Bayes algorithm (CIC-MalMem-2022 dataset). 4.2.2 K-Nearest Neighbours (Hamming Distance) By applying the Hamming distance metric and employing the same hyperparameters in the CIC-Evasive-PDFMal2022 dataset, we obtain the results shown in figure 34. Figure 34: KNN (Hamming distance) results for 1 <random state <100, 1% <test size <50% and K = 3 (CIC-MalMem-2022 dataset). 37 We can improve those results searching the best hyperparameters, as we did for CIC- Evasive-PDFMal2022 dataset (figure 35). Figure 35: KNN (Hamming distance) results for 1 <random state <100, 1% <test size <50% and K = 1 (CIC-MalMem-2022 dataset). 4.2.3 Decision Tree Using the same hyperparameters as in the CIC-Evasive-PDFMal2022 dataset (criterion = Gini Impurity, splitter = best, max depth = 11, min samples split = 2, min samples leaf = 1), we obtain the results shown in figure 36. Figure 36: Decision tree results for 1 <random state <100, 1% <test size <60% and max depth = 11 (malware detection with CIC-MalMem-2022 dataset). In this case, the precision, recall and accuracy values keep more or less constant for a lot of test size values. For example, even for a test size = 60%, these values are still higher than 99.9%. However, we can improve those results searching the best hyperparameters, as we did for CIC-Evasive-PDFMal2022 dataset (figure 37). We also found that the best results are obtained using a test size = 60% 38 Figure 37: Accuracy average (left) and variance (right) obtained for different max depth and test size = 0.17 (malware detection with CIC-MalMem-2022 dataset). 4.2.4 Random Forest Using the same hyperparameters as in the CIC-Evasive-PDFMal2022 dataset (the same used for the Decision Tree and Number of trees = 20), we obtain the next results: [’Time: 170s’] [’number of trees: 20’, ’max depth: 11’, ’test size: 0.15’, ’precision: 0.99985’, ’recall: 0.99997’, ’accuracy: 0.99991’] [’precision variance: 3.54930e-08’, ’recall variance: 5.10328e-09’, ’accuracy variance: 9.55808e-09’] In figure 38, the results obtained searching the best hyperparameters (as we did for CIC- Evasive-PDFMal2022 dataset) are shown. Figure 38: Random Forest results (obtained with max depth = 7 and test size = 0.17) with CIC-MalMem-2022 dataset. In this case, the results obtained are a little bit lower than for the ones obtained with the CIC-Evasive-PDFMal2022 hyperparameters. However, the max depth is lower, which will result in a lower computation time (106s). 39 4.2.5 Support Vector Machine Using the same hyperparameters as in the CIC-Evasive-PDFMal2022 dataset (C = 125 and gamma = 0.07), we obtain the next results: [’C: 125’, ’gamma: 0.07’, ’test size: 0.15’, ’precision: 0.99978’, ’recall: 0.99994’, ’accuracy: 0.99986’] [’precision variance:3.82173e-08’, ’recall variance:1.17065e-08’, ’accuracy variance:1.26217e-08’] We can improve those results searching the best hyperparameters, as we did for CIC- Evasive-PDFMal2022 dataset (figure 37). Figure 39: SVM results (obtained with C = 11, gamma = 0.03 and test size = 0.15) with CIC-MalMem-2022 dataset. 4.2.6 Summary In short, the results obtained using the hyperparameters found with CIC-Evasive-PDFMal- 2022 and CIC-MalMem-2022 datasets are very similar. Thus, we can use the hyperparameters obtained with the CIC-Evasive-PDFMal2022 dataset for simplicity, instead of recalculating them for the CIC-MalMem-2022 dataset. In table 8 we can see a summary of the results obtained, where “Time” is the average computation time for 100 simulations with different random states. Algorithm Specifications Precision Recall Accuracy Time Naive Bayes Bernoulli 0.99168 0.99572 0.99369 15s KNN Hamming distance, K = 3 0.99939 0.99952 0.99945 51min Decision Tree max depth = 11 0.99980 0.99985 0.99983 55s Random Forest Number of trees = 20 0.99978 0.99974 0.99976 170s SVM C = 125, gamma = 0.07 0.99978 0.99994 0.99986 347s Table 8: Detection results obtained using different algorithms with the CIC-MalMem-2022 dataset. As we can see, the computation times have increased for all the algorithms. This is because the CIC-MalMem-2022 dataset (58596 records) is larger than the CIC-Evasive- PDFMal2022 dataset (10025 records). In addition, the CIC-Evasive-PDFMal2022 dataset (55 features) has more features than the CIC-MalMem-2022 dataset (28 features). On the other hand, the best precision is obtained with the decision tree, while the best recall and accuracy are obtained with the SVM algorithm. 40 4.3 Malware classification with CIC-MalMem-2022 dataset In order to determine which algorithm is better for malware classification, we will evaluate the accuracy average and its variance for different random states and test sizes. We will also represent a confusion matrix that compares the real values of the target variables (benign, ransomware, spyware and trojan) with the predicted values by the model. 4.3.1 Naive Bayes Since Multinomial Naive Bayes is used for classification, we will start using it (figure 40). Figure 40: Accuracy average (left) and variance average (right) obtained for different test sizes with Multinomial Naive Bayes. We can choose, for example, a test size = 0.26, where we have a peak in the accuracy average value and the variance is pretty low. For this test size, we obtain the confusion matrix shown in figure 41. Figure 41: Multinomial Naive Bayes confusion matrix obtained for test size = 0.26. 41 4.3.4 Random Forest As for malware detection, each individual tree will be trained using the whole training subset [18], and we also need to find the number of trees to use in the algorithm. However, we do not need to find other hyperparameters (like the test subset size or the depth of each tree) because we already have them from the results of the Decision Tree. Figure 54: Random Forest results (obtained with max depth = 20 and test size = 0.18). In figure 54, we can see that the best accuracy average is obtained for a high number of trees. However, from 25 trees to up, the average values do not increase significantly: [’Number of trees: 25’, ’max_depth: 20’, ’test_size: 0.18’, ’accuracy: 0.87591’, ’accuracy_variance:7.22873e-06’] Thus, we will choose 25 trees to reduce the computation time as maximum as possible. The confusion matrix obtained for those hyperparameters is shown in figure 55. Figure 55: Random Forest confusion matrix obtained using 25 trees. 48 4.3.5 Support Vector Machine We could not obtain the best hyperparameters because the computation time is too high. To illustrate it, for example for only one random state the computation time is 146 seconds. This means that to determine the accuracy for 100 different random states we would need around 4 hours. Thus, for finding the best hyperparameters we would need much more time. However, we did a test to have an idea of which values would be obtained (figure 56). Specifically, we used test size = 0.15, C = 125 and gamma = 0.07. Figure 56: SVM confusion matrix obtained using C = 125 and gamma = 0.07. 4.3.6 Summary In table 9 a summary of the results obtained using different algorithms is presented, where “Time” is the average computation time for 100 simulations with different random states. Algorithm Specifications Time Percentage of records classified correctly Benign Ransomware Spyware Trojan Naive Bayes Bernoulli 0:11 min 98% 24% 32% 72% KNN Hamming distance, K = 1 41:12 min 100% 69% 73% 67% Decision Tree max depth = 20 1:58 min 100% 67% 73% 68% Random Forest Number of trees = 25 5:38 min 100% 74% 77% 73% SVM C = 125, gamma = 0.07 172 min 100% 65% 63% 67% Table 9: Classification results obtained using different algorithms with the CIC-MalMem-2022 dataset. In short, the best results are obtained with the Random Forest algorithm. However, the Decision Tree could be a better solution in some applications that require a lower computation time. As we can see, results are quite low because the dataset is unbalanced for malware classification. In other words, despite there is the same number of benign and malicious records, what we need is to have the same number of benign, ransomware, spyware and trojan records. Another possibility is that the features provided in the dataset are not the most appropriate to classify malware. Thus, maybe we should generate a new dataset, searching which are the best features for malware classification. 49 5 Conclusions and future development It is well known that cyberattacks have become a pervasive and persistent threat that can target a wide range of victims. However, with the increasing sophistication and diversity of malware, traditional signature-based detection methods are often insufficient. That is why we decided to use different machine learning algorithms to detect and classify malware, determining the precision, accuracy and recall averages for 100 different random states, as well as the variance of each one of these averages. To implement these machine learning algorithms, we used Python and the Scikit-learn, Matplotlib and NumPy libraries. Firstly, we used the CIC-Evasive-PDFMal2022 dataset (which consists of 10025 records with 5533 malicious and 4466 benign records) for detection. Specifically, with the Naive Bayes algorithm we obtained that the best results were achieved with the Bernoulli distribution for a big test size, while with the KNN algorithm the Hamming distance provides the best results. On the other hand, with Decision Tree and Random Forest we chose a low depth of the tree and a low number of trees (respectively) to avoid high computation times without decreasing the precision, recall and accuracy. Finally, in SVM we tried to reduce the computation time, reducing the number of features. However, this time did not decrease significantly. Thus, we kept the results obtained with all the 28 features. In short, the best results were obtained with Random Forest, but we achieved a lower computation time with Decision Tree, keeping the results very similar to the ones of Random Forest. In addition, for all the algorithms we tried also to find the best hyperparameters using “GridSearchCV”. The results obtained were more or less the same, but for higher hyperparameters values, which increased the computation time. Furthermore, “GridSearchCV” uses different random states that the ones we used before. This can result in little differences in the accuracy values, in the way that they are not exactly the same we found previously. Then, we used the CIC-MalMem-2022 dataset (which consists of 58596 records with 29298 malicious and 29298 benign records) for detection. We demonstrated that it is not mandatory to find new hyperparameters for this dataset. With the hyperparameters found for the CIC-Evasive-PDFMal2022 dataset results are good enough. In other words, there is not a huge difference in the results whether we use hyperparameters found with the CIC-Evasive-PDFMal2022 dataset or with the CIC-MalMem-2022 dataset. Finally, we did not use the CIC-Evasive-PDFMal2022 dataset for classification because it was not labeled with malware type. Therefore, we only used the CIC-MalMem-2022 dataset for classification. However, the computation time increased because the CIC- MalMem-2022 dataset is larger and has more features than the CIC-Evasive-PDFMal2022 dataset, as well as classification among 4 classes has a higher computational cost than detection (where we only had 2 classes). In addition, the percentage of records classified correctly was too low for all the algorithms. In this way, we realized that this dataset was unbalanced for classification (it has the same number of benign and malign records, but we need to have the same number of benign, ransomware, spyware and trojan records). We tried to balance it oversampling and undersampling it, but we could not improve the results. 50 Therefore, as future work we should try to balance the CIC-MalMem-2022 dataset for malware classification searching which specific features are strongly related with each class (benign, ransomware, spyware and trojan). On the other hand, we should finish the SVM malware classification section, which we could not complete because we would need a more powerful computer. Lastly, we could also try other algorithms as Gradient Boosting, Logistic Regression or even some deep learning algorithms and compare the results with the ones obtained in this thesis. 51 Glossary Below is the glossary for abbreviations and technical terms used in this research document: DoS: Denial of Service DT: Decision Tree FN: False Negative FP: False Positive KNN: K-Nearest Neighbours NB: Naive Bayes RBF: Radial Basis Function RF: Random Forest SMOTE: Synthetic Minority Over-sampling Technique SQL: Structured Query Language SVM: Support Vector Machine TN: True Negative TP: True Positive XSS: Cross-Site Scripting CSRF: Cross-Site Request Forgery 52 References [1] Kurt Baker. 10 most common types of cyber attacks, 13 Feb 2023. URL https://www.crowdstrike.com/cybersecurity-101/cyberattacks/mostcommon-types-of-cyberattacks/. Last accessed: 21 Jun 2023. [2] Elizabeth Fichtner. Common types of cyber attacks, 31 Jan 2022. URL https: //www.datto.com/blog/common-types-of-cyber-security-attacks. Last accessed: 21 Jun 2023. [3] Nabeel Albishry. An attribute extraction for automated malware attack classification and detection using soft computing techniques, 25 Apr 2022. URL https://www. ncbi.nlm.nih.gov/pmc/articles/PMC9061036/. Last accessed: 21 Jun 2023. [4] What is machine learning? a definition, 14 Mar 2022. URL https://www.expert. ai/blog/machine-learning-definition/. [5] Sabita Rajbanshi. Everything you need to know about machine learning, 30 Mar 2021. URL https://www.analyticsvidhya.com/blog/2021/03/everything-you- need-to-know-about-machine-learning/. Last accessed: 11 Feb 2023. [6] Tanvi Penumudy. A beginner’s guide for getting started with machine learning, 29 Dec 2020. URL https://medium.com/analytics-vidhya/a-beginners-guide- for-getting-started-with-machine-learning-7ba2cd5796ae. Last accessed: 11 Feb 2023. [7] Volodymyr Bilyk. Guide to supervised machine learning, 26 May 2020. URL https://volodymyrbilyk.medium.com/guide-to-supervised-machine- learning-324b3e970708. Last accessed: 11 Feb 2023. [8] Randy Lao. A beginner’s guide to machine learning, 22 Jan 2018. URL https://medium.com/@randylaosat/a-beginners-guide-to-machine- learning-dfadc19f6caf. Last accessed: 11 Feb 2023. [9] Rahul Shah. Tune hyperparameters with gridsearchcv, 23 Jun 2021. URL https://www.analyticsvidhya.com/blog/2021/06/tune-hyperparameters- with-gridsearchcv/. Last accessed: 13 Mar 2023. [10] Tanvi Penumudy. A machine learning roadmap to naive bayes, 17 Jan 2021. URL https://medium.com/analytics-vidhya/a-machine-learning- roadmap-to-naive-bayes-66437a48d9f3. Last accessed: 11 Feb 2023. [11] Tanvi Penumudy. A beginner’s guide to knn and mnist handwritten digits recognition using knn from scratch, 10 Jan 2021. URL https://medium.com/analyticsvidhya/a-beginners-guide-to-knn-and-mnist-handwritten-digits- recognition-using-knn-from-scratch-df6fb982748a. Last accessed: 13 Feb 2023. [12] Kunal Gohrani. Different types of distance metrics used in machine learning, 10 Nov 2019. URL https://medium.com/@kunal_gohrani/different-types-of- 53 distance-metrics-used-in-machine-learning-e9928c5e26c7. Last accessed: 06 Mar 2023. [13] Avinash Navlani. Decision tree classification in python tutorial, Feb 2023. URL https://www.datacamp.com/tutorial/decision-tree-classification-python. Last accessed: 25 Feb 2023. [14] Tanvi Penumudy. Decision trees for dummies, 12 Jan 2021. URL https://medium. com/analytics-vidhya/decision-trees-for-dummies-a8e3c00c5e2e. Last accessed: 25 Feb 2023. [15] Decision trees explained with a practical example, 28 May 2020. URL https://towardsai.net/p/programming/decision-trees-explained-with- a-practical-example-fe47872d3b53. Last accessed: 03 Mar 2023. [16] Himanshi Singh. How to select best split in decision trees using gini impurity, 22 Mar 2021. URL https://www.analyticsvidhya.com/blog/2021/03/how-to-select- best-split-in-decision-trees-gini-impurity/. Last accessed: 11 Mar 2023. [17] Tanvi Penumudy. Random forest: Simplified, 12 Jan 2021. URL https://medium. com/analytics-vidhya/random-forest-simplified-98da251c7522. Last accessed: 27 Feb 2023. [18] sklearn.ensemble.randomforestclassifier. URL https://scikit-learn.org/ stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html. Last accessed: 27 Feb 2023. [19] Tony Yiu. Understanding random forest, 12 Jun 2019. URL https:// towardsdatascience.com/understanding-random-forest-58381e0602d2. Last accessed: 11 Mar 2023. [20] Tanvi Penumudy. A beginner’s introduction to svm, 17 Jan 2021. URL https://medium.com/analytics-vidhya/a-beginners-introduction-to- svm-c641c3ff2769. Last accessed: 02 Mar 2023. [21] Saumya Awasthi. Seven most popular svm kernels, 17 Dec 2020. URL https:// dataaspirant.com/svm-kernels/#t-1608054630725. Last accessed: 23 Jun 2023. [22] Aman Gupta. Kernel tricks in support vector machines, 29 Apr 2021. URL https://medium.com/geekculture/kernel-methods-in-support-vector- machines-bb9409342c49. Last accessed: 23 Jun 2023. [23] Soner Yıldırım. Hyperparameter tuning for support vector machines — c and gamma parameters, 31 May 2020. URL https://towardsdatascience. com/hyperparameter-tuning-for-support-vector-machines-c-and-gamma- parameters-6a5097416167. Last accessed: 02 Mar 2023. [24] Czako Zoltan. Svm and kernel svm, 13 Nov 2018. URL https:// towardsdatascience.com/svm-and-kernel-svm-fed02bef1200. Last accessed: 12 Mar 2023. 54 [25] Pushkar Mandot. What is the significance of c value in support vector machine?, 09 Sep 2017. URL https://medium.com/@pushkarmandot/what-is-the- significance-of-c-value-in-support-vector-machine-28224e852c5a. Last accessed: 02 Mar 2023. [26] The a-z guide to support vector machine, 16 Jun 2021. URL https: //www.analyticsvidhya.com/blog/2021/06/support-vector-machine-better- understanding/. Last accessed: 02 Mar 2023. [27] scikit-learn. machine learning in python. URL https://scikit-learn.org/ stable/. Last accessed: 23 Jun 2023. [28] Victor Roman. Introducci´on al machine learning: Una gu´ıa desde cero, 06 Feb 2019. URL https://medium.com/datos-y-ciencia/introduccion-al-machine- learning-una-gua-desde-cero-b696a2ead359. Last accessed: 11 Feb 2023. [29] Datasets. URL https://www.unb.ca/cic/datasets/index.html. Last accessed: 08 Apr 2023. [30] Cic-evasive-pdfmal2022, 2022. URL https://www.unb.ca/cic/datasets/pdfmal- 2022.html. Last accessed: 23 Jun 2023. [31] Cic-malmem-2022, 2022. URL https://www.unb.ca/cic/datasets/malmem-2022. html. Last accessed: 23 Jun 2023. [32] Patricia Ryser-Welch. Ratio between a training set and validation set, 16 Mar 2016. URL https://www.researchgate.net/post/Is-there-an-ideal-ratio- between-a-training-set-and-validation-set-Which-trade-off-would-you- suggest. Last accessed: 23 Jun 2023. [33] Kishan Modasiya. What is random state?, 25 Jun 2022. URL https://medium.com/ mlearning-ai/what-the-heck-is-random-state-24a7a8389f3d. Last accessed: 05 Apr 2023. [34] Cross-validation, . URL https://docs.aws.amazon.com/machine-learning/ latest/dg/cross-validation.html. Last accessed: 23 Jun 2023. [35] Ccross-validation: evaluating estimator performance, . URL https://scikitlearn.org/stable/modules/cross_validation.html. Last accessed: 23 Jun 2023. [36] Sarang Narkhede. Understanding confusion matrix, 09 May 2018. URL https: //towardsdatascience.com/understanding-confusion-matrix-a9ad42dcfd62. Last accessed: 03 Mar 2023. [37] Lourdes Bruna. Tfm, 25 Jun 2023. URL https://github.com/lourdesbruna/TFM. Last accessed: 23 Jun 2023. [38] What does ”splitter” attribute in sklearn’s decisiontreeclassifier do?, 15 Oct 2017. URL https://stackoverflow.com/questions/46756606/what-does-splitter- attribute-in-sklearns-decisiontreeclassifier-do. Last accessed: 23 Jun 2023. 55 [39] Himanshi Singh. How to select best split in decision trees using gini impurity, 30 Mar 2021. URL https://www.analyticsvidhya.com/blog/2021/03/how-to-select- best-split-in-decision-trees-gini-impurity/. Last accessed: 23 Jun 2023. [40] Gianluca Malato. A practical introduction to sequential feature selection, 15 Feb 2023. URL https://www.yourdatateacher.com/2023/02/15/a-practical- introduction-to-sequential-feature-selection/. Last accessed: 13 Jun 2023. [41] Sebastian Raschka. Sequentialfeatureselector: The popular forward and backward feature selection approaches (including floating variants). URL https://rasbt.github.io/mlxtend/user_guide/feature_selection/ SequentialFeatureSelector/. Last accessed: 13 Jun 2023. 56