# Machine-Learning-Enabled Intrusion Detection System for Cellular Connected UAV Networks
## 4 ML Approaches to Detect Attacks  
There are many ways to create security in UAV networks, and among them, we use anomaly detection using ML algorithms in order to increase the accuracy of 5G-transmitted packets. Anomaly detection is not a novel field of research in machine learning systems, and recent research has focused on a wide range of machine -learning-based applications. First of all, 5G packets are recorded in the network. More clearly, we gather a total number of records, which are divided into two classes, including the number of normal records and attack records. In the considered dataset, 80% is allocated to train ML algorithms and 20% for testing algorithms. After training the mentioned ML algorithms, in testing records, a number of randomly selected packets are used for detecting legitimate or attack packets. Thus, UAVs based on 5G networks can be evaluated by these real data. Moreover, this structure operates like a firewall that controls and eavesdrops on 5G-based UAV data. If controlled data are confirmed as correct, then they can pass through the other nodes of networks, but if they are detected as an attack, then they is not allowed to enter the network. The rest of section provides a review of machine learning algorithms that are applied in this paper. Three major types of ML algorithms, namely supervised learning, unsupervised learning, and semi-supervised learning, can be widely applied in UAV networks in order to increase network security. The ML classifiers used in this paper are: Logistic Regression (LR), Linear Discriminant Analysis (LDA), K-nearest Neighbor (KNN), Decision Tree (DT), Gaussian Naive Bayes (GNB), Stochastic Gradient Descent (SGD), and K-means (K-M). These ML classifiers add a label to the network features of UAV nodes in order to create a  
Figure 10: Intrusion detection system classification. classification or regression model [60; 61]. A brief description of the mentioned algorithm are discussed as follows:  
* LR Algorithm: This method is applied for binary classification problems with two class values. Logistic regression is widely used to evaluate and explain the relationship between a binary real variable such as success or failure and predictor variables. It uses a logistic function for classification logistic regression. Modeling the mean of the response variable for a given set of predictor variables is one of the significant objectives of this algorithm [62]. * LDA: LDA is a well-known method to reduce and classify the projects that have high-dimensional data and create low-dimensional space to efficiently obtain a separate maximum class. In fact, an LDA classifier linearly combines original features. By simultaneously minimizing the samples of a class distance and maximizing distance between class categories, optimal design in LDA algorithm can be achieved [63]. * KNN: For both classification and regression objectives, KNN is an ideal choice in predictive problems. However, most of its applications are related to classification problems in the industry. It has three prominent benefits, including easy interpretation of output, predictive power, and calculation time. The classification is done based on the majority of neighbors of the considered case. This means the case is assigned to the class where the most similarities are observed among its K nearest neighbors, calculated using a distance function. * DT: In DT, a decision-making method is used that is a tree-like model of the decisions and their potential outcomes that helps to reach a goal. In a DT classifier, a collection of test questions and conditions are designed in a tree shape. The internal nodes in DT include test conditions to divide records, which have different features. A class label including success or failure is assigned to all the terminal nodes. Then, DT recursively selects the best features to separate the data and develops the clusters as the leaf nodes of the tree until its iteration criterion is met.