scieee AI-readable full text Open interactive document viewer

Shallow neural network with kernel approximation for prediction problems in highly demanding data networks

López Martín, Manuel,Carro Martínez, Belén,Sánchez Esguevillas, Antonio Javier,Lloret, Jaime

Abstract

Producción Científica

Full text

1 Shallow neural network with kernel approximation for prediction problems in highly demanding data networks Manuel Lopez-Martin, Belen Carro, Antonio Sanchez-Esguevillas and Jaime Lloret Abstract— Intrusion detection and network traffic classification are two of the main research applications of machine learning to highly demanding data networks e.g. IoT/sensors networks. These applications present new prediction challenges and strict requirements to the models applied for prediction. The models must be fast, accurate, flexible and capable of managing large datasets. They must be fast at the training, but mainly at the prediction phase, since inevitable environment changes require constant periodic training, and real-time prediction is mandatory. The models need to be accurate due to the consequences of prediction errors. They need also to be flexible and able to detect complex behaviors, usually encountered in non-linear models and, finally, training and prediction datasets are usually large due to traffic volumes. These requirements present conflicting solutions, between fast and simple shallow linear models and the slower and richer non-linear and deep learning models. Therefore, the perfect solution would be a mixture of both worlds. In this paper, we present such a solution made of a shallow neural network with linear activations plus a feature transformation based on kernel approximation algorithms which provide the necessary richness and non-linear behavior to the whole model. We have studied several kernel approximation algorithms: Nystrom, Random Fourier Features and Fastfood transformation and have applied them to three datasets related to intrusion detection and network traffic classification. This work presents the first application of a shallow linear model plus a kernel approximation to prediction problems with highly demanding network requirements. We show that the prediction performance obtained by these algorithms is positioned in the same range as the best non-linear classifiers, with a significant reduction in computational times, making them appropriate for new highly demanding networks. Index Terms—shallow neural network; kernel approximation; intrusion detection; network traffic classification. * Correspondence: manuel.lopez[email protected]; Tel.: +34-983-423-980, Fax: +34-983-423-667 The authors declare that there is no conflict of interest regarding the publication of this paper 1. INTRODUCTION Considering the importance of current security attacks on modern networks with the highest demands (e.g. IoT networks), the economic importance of services running on these networks and the increased demands on data networks imposed by these services, it is more important than ever to rely on new automatic systems capable of detecting intrusions in a fast and reliable manner. Such a system is an Intrusion Detection Systems (IDS) (Bhuyan, Bhattacharyya & Kalita, 2014), being its final goal to fast and accurately analyze network traffic and to predict potential threats. Similarly, Network Traffic Classification (NTC) (Nguyen & Armitage, 2008; Lopez-Martin et al, 2017a) is also an important prediction task in data networks. NTC uses network traffic information to predict the type of services of a network flow. This prediction is important to address network management and quality of service tasks which are dependant of the type of service of the data connection. IDS and NTC are identified as two of the main research applications of machine learning for data networking (Wang et al, 2018; Kim, 2018) and are representative of many other applications. Both IDS and NTC present important prediction problems for data networks. Both deal with large, noisy, unbalanced and complex data. The labels to predict have a very (sometimes extremely) unbalanced distribution. The data to process, in both problems, is usually large, and, the features extracted from the network traffic are complex with usually a noisy assignment of labels to its corresponding ground-truth state, due to the difficulty to ascertain the true value of the intrusion state (with manual detection or intrusion detection tools) or type of traffic (with deep packets inspection tools). This work has manifold objectives: (1) To demonstrate that shallow linear models can be a competitive alternative to more complex models, when former models are used together with a feature transformation based in kernel approximation (KA) theory. Simple linear models with a feature transformation based on KA have the prediction and training speeds of a simple M. Lopez, B. Carro and A. Sanchez are with Dpto. TSyCeIT, ETSIT, Universidad de Valladolid, Paseo de Belén 15, Valladolid 47011, Spain; (manuel.lopez[email protected]; [email protected]; [email protected]). J. Lloret is with Instituto de Investigación para la Gestión Integrada de Zonas Costeras, Universitat Politècnica de València, Camino Vera s/n, Valencia 46022, Spain; (jllor[email protected]s). Expert Systems with Applications. Volume 124, 2019, Pages 196-208. https://doi.org/10.1016/j.eswa.2019.01.063 2 linear model and the detection performance of complex non-linear models (e.g. kernel-Support Vector Machines) or deep learning models (e.g. Convolutional Neural Networks), making them a perfect alternative for prediction problems in data networks. (2) To analyze the different architectural alternatives for the linear model and KA transformations and justify the reasons for the selected architecture. (3) To propose a model that can be trained with a differentiable loss function in modern high-performance platforms (e.g. Tensorflow). (4) To provide a thorough comparison of our proposed model with several Machine Learning (ML) models for some important and representative prediction problems in data networks (e.g. IDS and NTC), with a focus in prediction performance, prediction and training times, model flexibility, model richness and capacity to deal with large datasets. In order to generalize as much as possible the results obtained, to as many prediction problems as possible, we have compared all the models using three different datasets: NSL-KDD (Tavallaee et al, 2009), ADFA UNSW-NB15 (Nour & Slay, 2015; Nour & Slay, 2016) and Moore (Wei et al, 2009) datasets, each with different characteristics and objectives (Section 3.1): two datasets are related with intrusion detection systems (IDS) and one with network traffic classification (NTC). The proposed model consists of a linear classifier based on a Neural Network (NN) with linear activations, with a previous KA transformation (Section 3.2) of the input features. The study covers several variants of KA transformations based on different algorithms: Nystrom, RFF and Fastfood transform (Rahimi & Recht, 2007; Yang et al, 2012; Le, Sarlos & Smola, 2014). Feature transformation based on KA provides non-linearity in the transformed feature space, which is necessary to give flexibility and richness to pattern detection. We have also studied different configurations for the linear model, all of them based on a linear NN with different activation and loss functions, extracting interesting conclusions about the best architectures for this task. To evaluate the model’s performance, we have compared it with the following supervised machine learning models: Linear and Radial Basis Function (RBF) Support Vector Machine (SVM), Multilayer Perceptron (MLP), Gradient Boosting Machine (GBM), Random Forest, AdaBoost, Multinomial Logistic Regression and Convolutional Neural Networks (CNN). The comparison was implemented for the three datasets. Considering the dependence of the results when performing a classification with a different number of labels, we repeated the experiment for the three datasets considering two groups of results: one with a binary classification and another with a multiclass classification. In addition, a Wilcoxon signed-rank test guarantees the significance of the results. Along with the importance given to classification performance metrics, we provide an exhaustive study of the training and prediction times of the different algorithms considered for the study. Computation times are of crucial importance when the classification must be carried out in time-critical scenarios or when changes in the environment demand flexibility and rapid reaction of the proposed classifier. There is extensive theoretical work that studies the reasons why neural network architectures based on a hierarchy of layers (deep networks) provide better prediction results than those based on single layer networks (shallow networks). The classic work by Bengio & LeCun (2007) claims that most functions that can be represented compactly by deep architectures cannot be represented by a compact shallow architecture. Other studies support that, although theoretically both shallow and deep networks possess the universal approximation property, deep networks can do so with a much smaller number of parameters and complexity (Mhaskar, Liao & Poggio, 2016; Bianchini & Scarselli, 2014). There are also works presenting the theoretical limitations of shallow networks (Kurkova & Sanguineti, 2017; Lin, 2017). And, in Ba & Caruana (2014) there is an interesting study that shows that shallow networks can get results as good or even better than deep networks, but when they are trained to simulate the results of another deep network, in this way, the focus is placed not only on the intrinsic inabilities of shallow architectures, but rather on the difficulties to train them adequately. These theoretical results, which establish the superiority of deep networks to approximate complex functions, make more interesting the practical conclusions of this study, showing that, with the addition of the KA transformation, a shallow network can produce results as good as those delivered by deep networks, at least for a representative class of prediction problems encountered in data networking. The paper is organized as follows: Section 2. identifies related works. Section 3 presents the work performed and the models analyzed in the paper. Section 4 shows the results obtained and finally, Section 5 provides discussion and conclusions. 2. RELATED WORKS There are no works presenting results of the application of linear models plus KA transformations for IDS and NTC problems, but there are many considering other prediction models. In this section we present the most representative of these works applied to the NSL-KDD, UNSW-NB15 and Moore datasets. Being a mature dataset there are many works providing results for classification models applied to the NSL-KDD (Tavallaee et al, 2009) dataset: In Ingre & Yadav (2015), applying an MLP with three layers, they report an accuracy of 79.9% for test data for the 5-labels prediction scenario. For the scenario of 2-label prediction, it is obtained an accuracy of 81.2% for test data. 3 Authors in Ibrahim, Basheer & Mahmood (2013), for the 2-labels scenario and using Self Organizing Maps (SOM), report a recall of 75.49% on test data. The work in Panda, Abraham & Patra (2010) for the 2-labels scenario, and using Naive Bayes with several feature engineering methods, reports an accuracy of 96.5% but the test set used is unclear. Similarly, in Dhanabal & Shantharajah (2015) they report an accuracy of 99.1% using several methods (SVM, NB...) with a previously performed dimensionality reduction on the features, but again, it is not clear the test set used, and the metrics are given on subsets of the anomaly types. Again, in Kamel et al. (2016) they report an accuracy of 99.9% with AdaBoost and a selection of features using a wrapper model; they use a subset of the NSL-KDD dataset for training and an unclear test set. In Patil & Pattewar (2014) for the 2-labels scenario and using AdaBoost with weak learners being simple decision stumps, they report a detection rate of 90% on test data. In Wahb, ElSalamouny & ElTaweel (2015) using AdaBoost with Naive Bayes as weak learner and a previous feature selection, they report an F1 of 98% for the 5-labels scenario; test results are based on 10-fold cross validation over the training data, not on the test set. The work in Bhuyan, Bhattacharyya & Kalita (2014) explains why and how the NSL-KDD data set was created. They provide results of applying several methods to the NSL-KDD data. The best accuracy reported is 82.02% with Naive Bayes Tree using Weka. They use the full NSL_KDD dataset for training and testing for the 2-labels prediction scenario. Finally, in Lopez-Martin et al (2017b) is proposed a variational autoencoder to perform detection on NSL-KDD with a 5-labels configuration obtaining an overall accuracy of 80%. Compared with NSL-KDD, the UNSW-NB15 (Nour & Slay, 2015; Nour & Slay, 2016) is a much modern dataset for intrusion detection with a larger training and test set. There are several works that present prediction results for this dataset: In Moustafa & Slay (2017) three classification algorithms; Expectation-Maximization (EM) clustering, Logistic Regression (LR) and Naive Bayes (NB) are applied to UNSW-NB15 achieving a best accuracy of 83% for LR, with a previous feature selection based on the central points of attribute values and an Association Rule Mining algorithm. These results are obtained with the 2-labels configuration of the dataset. With the same 2-labels configuration, five models are used in Nour & Slay (2016): NB, Decision Tree (DT), Artificial Neural Network (ANN), LR and EM Clustering, with DT obtaining the best classification accuracy (85.56%). In Khammassi & Krichen (2017) the authors employ a DT to achieve an accuracy of 81.42% for the 2-labels configuration; previously they apply a feature selection wrapper approach, based on a combination of genetic and logistic regression algorithms to select the best subset of features. In Belouch, ElHadaj & Idhammad (2017) a previous separation of TCP and UDP traffic is performed for training with a Reduced Error Pruning Tree (REPTree) algorithm, obtaining an accuracy of 88.9% for the 2-labels and 81.2% for the 10-labels configuration of the UNSW-NB15 dataset. The Moore (Wei et al, 2009) dataset is a well-known dataset for classification of network traffic from Cambridge University. There are several works reporting prediction results for this dataset: In Zhou et al. (2011) an MLP is applied in to the Moore dataset obtaining a classification accuracy of 96% for a 10-labels configuration of the dataset. A very similar accuracy is achieved in Hao et al. (2015), for the same dataset, using a Directed Acyclic Graph-Support Vector Machine. And, in Yuan & Wang (2016) is presented a modification of the C4.5 decision tree algorithm to classify a 12-labels configuration of the Moore dataset, reporting a one vs. rest accuracy moving between 60-90%, depending on the label, with only two labels with an accuracy higher than 90%. Authors of the Moore dataset propose in Zuev & Moore (2005) a Naïve Bayes classifier with an average accuracy of 66%, which is further improved by refinements in Moore & Zuev (2005) to achieve an accuracy of 95%. These refinements consist in a Naïve Bayes model based on kernel-estimates and feature selection based on Fast Correlation-Based Filter (FCBF). Finally, in Wei et al. (2009) same authors propose a better model using C4.5 obtaining an accuracy of 94-99% depending on the data configuration used for training and test. There are few works that apply KA techniques to data networks prediction problems: In Gao, Wang & Yang (2006) and Movahedi et al. (2015) are presented several KA methods applied to intrusion detection. They use KA with the LS-SVM model to reduce the dimensionality of the input dataset. They apply the model to the KDD-99 dataset with results not comparable to results from NSL-KDD. There is no reported work applying KA methods for NTC. There is a modern work (May, 2018) presenting the application of KA methods for speech recognition. It has been applied to visual recognition in Bo & Sminchisescu (2009) with results comparable to best known methods with a significant reduction in training and prediction times. 3. WORK DESCRIPTION In this Section we describe the datasets chosen to carry on the experiments, the different variants of KA algorithms used for feature transformation and the best model that we believe can tackle the diverse requirements imposed to data networks problems, which are: (1) fast prediction and training times, (2) to deal with unbalanced, noisy and large datasets, and (3) to detect complex and non-linear patterns in the data. The datasets employed are described in Section 3.1. The proposed model is presented in detail in Section 3.2. 4 3.1 Selected datasets To verify the capabilities of the proposed model in an environment as close as possible to the different requirements imposed by a prediction problem in a data network, we have selected three well-known datasets designed with different objectives: the NSL-KDD datasets (Tavallaee et al, 2009), ADFA UNSW-NB15 (Nour & Slay, 2015) (Nour & Slay, 2016) and Moore (Wei et al, 2009). Each one offers the opportunity to evaluate the performance of the models under different restrictions and goals. Two of the datasets are related to IDS and one to NTC. They vary in size from medium to large and with different distributions of continuous and categorical variables. All datasets are intended for classification. 3.1.1 NSL-KDD dataset (intrusion detection) The NSL-KDD (Tavallaee et al, 2009) dataset is a well-known IDS dataset. It solves the problem of redundant records in the KDD-99 (Tavallaee et al, 2009) dataset, which causes the learning algorithms to be biased towards the more frequent records. For this reason, the detection scores on the KDD99 are usually much higher than for the NSL-KDD dataset. The NSL-KDD dataset has 125973 training samples and 22544 test samples, with 41 features: 38 continuous and 3 categorical (discrete valued). We have performed a data preparation consisting of: scaling the continuous features to the range [0–1] and one-hot encoding the categorical features. This provides a final dataset with 122 features: 38 continuous and 84 with binary values ({0, 1}) associated to the three categorical features (one-hot encoded). NSL-KDD is a highly unbalanced dataset with a frequency of 43.1% and 1.7% for the most and least frequent labels. Each training sample has a label output from 23 possible labels (normal plus 22 labels associated to different types of anomaly). However, the test dataset has 38 label values, implying that the test data has anomalies not presented at training time. Both datasets have 21 labels in common; 2 labels only appear in training and 17 labels are unique to the test dataset. Up to 16,6% of the samples in the test dataset correspond to labels unique to the test dataset, and not used for training. The existence of new labels at testing introduces an additional challenge to the classifiers. Additionally, to facilitate interpretation of results the labels have been grouped into significant categories. As presented in Tavallaee et al. (2009), we have used five categories: NORMAL, PROBE, R2L, U2R and DoS, where NORMAL implies no intrusion. We have considered these five categories as the final labels driving our results (Section 4). The aggregation into these five categories still maintains a fairly unbalanced distribution of labels (an important feature of intrusion data) and with a number of samples, for each category, large enough to provide meaningful results. The results presented in Section 4 for this dataset also include a different prediction setup for two labels (NORMAL and INTRUSION values). In this case, the INTRUSION value corresponds to any original label different to NORMAL. This twolabels setup has been included to assess the performance of the model under different number of prediction labels. 3.1.2 UNSW-NB15 dataset (intrusion detection) The UNSW-NB15 (Nour & Slay, 2015; Nour & Slay, 2016) is a much more modern IDS dataset than NSL-KDD. It was released in 2015. It includes a mixture of normal network activity with modern attack type behaviors and modern normal traffic scenarios. The dataset consists of 2540044 samples with a test set of 82332 samples. It is also provided a training subset of 175341 samples, which has been used in this work. This is a larger dataset than NSL-KDD and includes nine attack types, and 42 useful features that are created by summarizing the information of the data packets exchanged in real network dataflows. The 42 features are divided into continuous (39) and categorical (3), which after one-hot encoding produce a final dataset with 196 features. The continuous features are also scaled to the range [0-1]. Similar to the NSL-KDD dataset, labels (attack types) are very unbalanced, with a frequency of 44.9% for the most frequent label (NORMAL) and 0.05% for the least frequent. Unlike NSL-KDD, the distribution of labels for the training and test sets is similar for this dataset. The results in Section 4 for this dataset also include a configuration of two labels (NORMAL and INTRUSION values), with the value of INTRUSION associated with any of the nine attack types. For the same IDS classification problem, this dataset provides different constraints and challenges to the ones imposed by the NSL-KDD dataset, which allows a better generalization of the results obtained (Section 4) 3.1.3 Moore dataset (network traffic classification) The Moore (Wei et al, 2009) dataset is intended for NTC classification. It is a large dataset with 12 continuous features and over 1 million samples. All the features are continuous. The dataset does not provide a test set; therefore, we have constructed one from a random subset of 20% of the original samples, holding the distribution of labels in both the resulting training and test sets. The features for this dataset are obtained by summarizing (e.g. median, variance of bytes in packets…) information contained in the first five packets of each network data flow. A window size of five packets is considered by the authors of this dataset as optimal to achieve good classification results. The dataset includes 15 labels associated to different types of network traffic (e.g. WWW, MAIL, P2P, VoIP…). It is 5 extremely unbalanced with a frequency of 83.9% and 0.0001% for the most and least frequent labels. In order to have a still unbalanced dataset but not so extremely unbalanced, we have aggregated the labels with a frequency less than 0.1% into a single label, resulting in a final dataset with 9 labels with the frequency for the most and least frequent labels being now 83.99% and 0.11% respectively. Similarly to the two other datasets we have included in Section 4 the results for this dataset when the 9 labels are aggregated into only two (WWW and REST). The only intention of this result is to present the prediction performances under a variety of comparable scenarios between datasets. This dataset provides a different scenario for classification, having only a small set of continuous features. 3.2 Model description When doing classification with linear models we try to find a linear decision surface that separate the classes. This surface is obtained as an inner product of a vector of weights (w), with the vector of features (x), given by: 〈w, x〉. But, in general, the classes are not linearly separable. In this case, a solution is to perform a projection of the vector of features into a higher dimensional vector space (ϕ(x)), where the associated classes can be linearly separable with a new linear decision surface, given by: 〈w, ϕ(x)〉. The parameters w can be obtained by some optimization mechanism (e.g. Stochastic Gradient Descent - SGD). To ensure linear separation, the best approach would be to perform the projection into a transformed space with a large number of dimensions, ideally an infinite number of dimensions, but that would make it impossible to calculate the required inner product. The Representer Theorem (Kimeldorf & Wahba, 1970) and Reproducing Kernel Hilbert Space theory (Girosi, 1998) provide a solution to this problem with the kernel trick that applies a kernel function: k(x, x′), such that: k(x, x′)=〈ϕ(x), ϕ(x′)〉 (1) That is, the inner product in the possibly infinite transformed space can be easily calculated with the kernel function in the original feature space. Applying this solution, the new decision surface is obtained by: 〈w, ϕ(x)〉 = 〈∑ αiϕ(xi), ϕ(x) N i=1 〉= ∑αik(xi,x) N i=1 (2) The parameters αi in (2) can be obtained by quadratic optimization (dual solution) (Scholkopf et al, 1999) as an alternative solution to obtaining the parameters w (primal solution) (Scholkopf et al, 1999). These principles are applied in the kernel-SVM model, usually with an RBF kernel. SVM is one of the best models for classification, being able to capture nonlinearity in the features, what is important to detect complex patterns. As will be shown later on this paper, SVM produces very good prediction results but has real problems in terms of time and resources needed to accomplish both training and prediction. The applicability of the dual solution depends on the number of samples and features, not being applicable when the number of samples is large, since that implies solving a problem of quadratic programming with huge matrices. When it is necessary to deal with datasets with a large number of samples (as is usually the case in IoT predictions), it is necessary to use the primal solution with its associated problem of non-applicability of the kernel trick. The kernel approximation (KA) algorithms comes as a way out in these cases, since they provide a projection into a higher dimensional space (but not infinite dimensional) with the property than the inner products in this transformed space are approximately equal to those obtained by applying the associated kernel. Classification problems in data networks generally have a large number of samples which require using the primal solution, and it makes it necessary to use a KA transform before applying a linear model. To implement the KA transformation there are several techniques. Section 3.3 gives details on the techniques used in this paper. Our proposed model is presented in Fig. 1, where the input data is the matrix X, composed of N samples of dimension d (d features). The input data is transformed to a higher dimensional space by a KA transform producing a new matrix Xt of dimensions N × D, where D ≫ d, and D being the dimension of the KA transformed data. The matrix Xt is multiplied by a matrix of weights W of dimensions D × M, generating an output matrix of results Y of dimensions N × M. The dimension M of the output vector corresponds with the M values of the predicted label (one-hot encoded). The matrix Z contains the ground truth values for the labels of the training data, with dimensions N × M . 6 Fig 1. Linear model with KA transformation of features. To learn the parameters of the weights matrix: W, we use SGD with a loss function shown in Fig. 1. The loss function corresponds to the average value through the samples of the sum of a hinge function applied to the difference between the values of Yj (the j position of vector Y) with the value of YZi associated with the index Zi of the correct output in Z. The parameter ∆ corresponds to the margin value, being ∆ = 1 for the hinge loss (linear SVM) or ∆ = 0 for the perceptron loss. The final term is a regularization term to penalize weights with big values; in this case we have used a L2 norm for regularization, the parameter λ being a hyperparameter to control the importance of regularization. To implement the model we have used Tensorflow as an efficient platform to perform automatic differentiation, to obtain the necessary gradients to minimize the loss function during training, and capable of handling large datasets. 3.3 Kernel approximation variants In order to implement kernel approximation, there are several techniques. We have employed Random Fourier Features (RFF) (Rahimi & Recht, 2007) and Nystroem Method (Yang et al, 2012) to approximate a Radial Basis Function kernel. Similarly, we have also applied a KA based on the Fastfood transformation (Le, Sarlos & Smola, 2014) which is a fast implementation of Random Kitchen Sinks (Rahimi & Recht, 2007) In the case of RFF (Rahimi & Recht, 2007), we create the new features using random Fourier basis (3): cos(ω′x + b) (3) where ω, x ∈ ℛd and b ∈ ℛ , being x the original data to be transformed, ω a random variable from a distribution obtained from the Fourier transform of the kernel, and b a random variable from a uniform distribution on [0, 2π]; both ω and x have the same dimensionality (d), which is the same as the number of initial features. The random mapping works using Bochner’s theorem (Rudin, 1994) which states that the Fourier transform of a shift-invariant positive definitive kernel is a proper probability distribution (Rahimi & Recht, 2007) The feature transformation will provide a feature map: ψ: ℛd→ ℛD (4) Which transforms d features to D features, where D is bigger than d, but not infinity, as would be necessary if we want to do the real mapping associated to the RBF feature map (5): ϕ: ℛd→ ℛ∞ (5) The important property of the transformation given by (4) is that the inner products of the approximated function (in this case the one associated to the RBF kernel) can be made similar to the inner products of the transformed data (as given in (6)): k(x, y)= 〈ϕ(x), ϕ(y)〉 ≈ ψ(x)′ψ(y) (6) 7 Where k(x, y) is the RBF kernel applied to samples x and y The objective of Nystroem Method is similar to RFF in obtaining a transformation similar to (4) but the method used is different. Nystroem Method implements a low-rank approximation to the Gram matrix (kernel matrix) using sampled columns of the original d x d Gram matrix (Yang et al, 2012; Drineas & Mahoney, 2005; Williams & Seeger, 2000). Nystroem method generally provides a better approximation to the true kernel transform, at the cost of increasing the required time to perform the transformation when the number of features is big. The Fastfood transformation is a fast implementation of Random Kitchen Sinks which approximate the function ϕ(x) by multiplying the input vector (original features) with a dense Gaussian random matrix, followed by the application of a nonlinearity. Fastfood operates in a similar way but replacing the dense Gaussian matrix by a combination of Hadamard and diagonal Gaussian matrices, which are more efficient to multiply and store (Le, Sarlos & Smola, 2014; Rahimi & Recht, 2007). In Fig. 2, are presented the times needed to perform the feature transformation for the different KA algorithms, depending on the number of transformed features. The dataset used has been NSL-KDD with 122 features (Section 3.1). We can see that Nystroem requires more time and that this time increases with the number of features. Fastfood starts to be competitive when the number of features is greater than 1000 (as predicted in Le, Sarlos & Smola (2014)). Similar results are obtained for the UNSWNB15 and Moore datasets. Fig 2. Time required to perform the KA transformation of features. 4. RESULTS In this section, we compare the results of applying different machine learning models to the NSL-KDD, UNSW-NB15 and Moore datasets, specifically the models are: Multinomial Logistic Regression, SVM with linear kernel and RBF kernel, Random Forest, GBM, AdaBoost with one weak learner (simple trees), MLP, CNN and our proposed model: Linear model + KA transformation. All results presented in this section are based in a neural network with no hidden layers (it consists just of the input and output layers), linear activation function for the last layer, and linear loss function (hinge loss) with a margin value for the hinge loss equal to zero (∆ = 0) and an L2 regularization parameter for the weights (λ) with values ranging between 10−3 and 10−4. This architecture, for the shallow neural network, is applied for all datasets and all configurations of labels (2-labels or multi-label). We have observed that this configuration provides best results, with small differences, for all datasets and models. The KA transformation that achieves best results does depend on the dataset. For the NSL-KDD the best KA transform has been the Nystroem method, with a number of transformed features equal to 400. The final model for the UNSW-NB15 consists of a KA transformation based in the Fastfood method with 512 features, and, finally, the Moore dataset obtains best prediction results with the RFF method with 512 generated features. It is interesting to note that a few hyperparameters are responsible for the greatest impact on the results. In particular, these hyperparameters are: a) the selection of the final KA method (RFF, Fastfood or Nystroem) and b) the number of features created by the KA transformation. This indicates that the initial feature transformation based on KA is a critical part of the proposed model. All results presented in this paper are based in the test sets defined in Section 3.1. To analyze the prediction performance for the different models, and considering the highly unbalanced distribution of labels, we provide the following performance metrics: accuracy, F1 score, precision and recall. We base our definition of these performance metrics on the usually accepted ones (Bhuyan, Bhattacharyya & Kalita, 2014). Regarding highly unbalanced datasets, F1 is considered a better metric for prediction performance than accuracy, precision and recall. This metric (F1) will be the metric used to rank the different algorithms applied to the three datasets. 8 For a binary classification there is no ambiguity to provide results, but, when facing a multi-class classification problem, there are two possible ways to give results: aggregated and One vs. Rest. For One vs. Rest, we focus in a particular class (label) and consider the other classes as a single alternative class, simplifying the problem to a binary classification task for each particular class (one by one). In the case of aggregated results, we try to give a summary result for all classes. There are different alternatives to perform the aggregation (micro, macro, samples, weighted), varying in the way the averaging process is done (Pedregosa et al, 2011). Considering the results presented in this paper, we have used the weighted average provided by scikitlearn (Pedregosa et al, 2011), to calculate the aggregated F1, precision and recall scores. Aggregated performance results for the NSL-KDD, UNSW-NB15 and Moore datasets are summarized in Fig. 3, 4 and 5 respectively. These figures are divided into two parts, with the upper part giving results for the 2-labels configuration of the datasets and the lower part for the multi-label configuration. (Section 3.1) Considering F1 as our main performance metric, the results in Fig. 3, 4 and 5 can be interpreted as follows: The NSL-KDD dataset (Fig. 3), highly noisy and with a difficult test set, has the SVM-RBF model as its best model for the configuration of 5- labels (followed immediately by the Linear+Nystroem model) and the Linear+Nystroem model as the best for the 2-labels configuration. The UNSW-NB15 dataset (Fig. 4) provides best results for the CNN-1D model, closely followed by Linear+Fastfood. This behavior occurs for both the configuration of 2 and 10-labels. For the Moore dataset (Fig. 5), with a large number of samples and a small number of features, the best results are obtained with the bagging and/or boosting models based on decision trees (random forest, GBM, Adaboost) and for the CNN-1D model, all of them highly non-linear and complex models. In this case, Linear+RFF is among the best models for the 2-label configuration and immediately behind them for the 5- labels configuration. The performances of MLP and SVM-RBF are not good for this dataset. From the results in Fig. 3, 4 and 5 we can conclude that Linear+KA models are among the best models for all three datasets and in all label configurations. It is important to mention several details about the different models applied in the study. For SVM with linear kernel, we have used the primal solution which provides a much faster implementation in our specific case (high number of samples and small number of features). For the SVM with RBF, we had to use the dual implementation. Results related to linear models plus KA transformation are provided using three KA methods: Nystroem (400 features), RFF (512 features) and Fastfood (512 features). We have implemented the MLP with several hidden layers (3 layers with 1024, 512 and 128 nodes). Considering the CNN model (Goodfellow, Bengio & Courville, 2016), we have applied the one-dimensional CNN due to the nature of the features in all datasets (no spatial allocation of features). Fig 3. Aggregated performance scores for the NSL-KDD dataset. 9 Fig 4. Aggregated performance scores for the UNSW-NB15 dataset. Fig 5. Aggregated performance scores for the Moore dataset.