# Improving Deep Learning-Based Recommendation Attack Detection Using Harris Hawks Optimization
## 3 Proposed Approach
### Detection Algorithms  
The original HHO algorithm is designed to search the optimal solution in the continuous numerical interval. It cannot perform the search and optimization in discrete candidate spaces. However, many key hyperparameters of the deep learning-based detection methods belong to the discrete type. To make HHO algorithm search and optimize discrete key hyperparameters, in this paper we propose a hyperparameter type conversion algorithm to convert the key hyperparameters from discrete to continuous. Figure 1: Proposed detection framework. As described in Section 2.2, the HHO algorithm randomly searches the optimal solution in the way of equal probability. That is, all candidate solutions have the same probability of being found. This constraint should also be satisfied when we map the discrete key hyperparameters to the continuous key hyperparameters. According to the probability theory, the probability density function of uniform distribution of continuous random variables is defined as follows [36]:  
\[f(x)= \begin{cases}\frac{1}{p-a},a<x<b\\ 0,\mathit{else}.\end{cases}  \tag{14}\]  
The uniform distribution has the following equal possibilities. If \(X\sim U[a,b]\), then the probability that \(X\) falls on any sub-interval \([c,d]\) in interval \([a,b]\) can be calculated as follows [36]:  
\[P(c\leq x\leq d)=\int_{c}^{d}f(x)dx=\int_{c}^{d}\frac{1}{b-a}dx=\frac{d-c}{b-a}. \tag{15}\]  
As shown in Equation (15), the probability is only related to the length of interval \([c,d]\). We assume that one key hyperparameter is a random variable with uniform distribution. Based on the uniform distribution theory, we only need to map the discrete candidate values to the continuous numerical spaces which have the same intervals. Then, when the HHO algorithm performs random search, the candidate values can be found with equal probability. According to above discussions, we propose a hyperparameter type conversion algorithm to convert the key hyperparameter from discrete to continuous as shown in Algorithm 1. ```
0: candidate values of a discrete key hyperparameter \([v_{1},\dots,v_{n}]\). 0: search range of each candidate value for the discrete key hyperparameter \(\mathit{Set}_{\mathit{ckh}}\). 1:\(\mathit{count}\gets 0\). //Set a counter. 2:\(\mathit{Set}_{\mathit{cv}}\leftarrow\emptyset\). 3:for each value \(v\) in \(\{v_{1},\dots,v_{n}\}\)do
4:\(\mathit{count}\gets\mathit{count}+1\). 5:\(\mathit{LB}_{v}\gets\mathit{count}-0.5\). //Search range lower bound of \(v\). 6:\(\mathit{UB}_{v}\leftarrow\mathit{count}+0.5\). //Search range upper bound of \(v\). 7:\(\mathit{Set}_{\mathit{cv}}\leftarrow\mathit{Set}_{\mathit{cv}}\cup\{[\mathit{ LB}_{v},\mathit{UB}_{v})_{v}]\). 8:endfor
9:\(LB\gets 0.5\). //Search range lower bound of the discrete key hyperparameter. 10:\(\mathit{UB}\leftarrow\mathit{count}+0.5\). //Search range upper bound of the discrete key hyperparameter. 11:\(\mathit{Set}_{\mathit{ckh}}\leftarrow\{[LB,\mathit{UB})\}\). 12:return\(\mathit{Set}_{\mathit{cv}}\),\(\mathit{Set}_{\mathit{ckh}}\). ```  
**Algorithm 1** Hyperparameter type conversion algorithm for converting the key hyperparameter from discrete to continuous. We take the activation function as an example to further illustrate Algorithm 1. The activation function is a key hyperparameter which is usually optimized manually in the deep learning-based detection methods [23; 25]. Suppose that the candidate values of the activation function contain [linear, sigmoid, tanh, elu, and selu]. These values are used as input of Algorithm 1. The corresponding outputs of Algorithm 1 are \(\{[0.5,1.5]_{linear},[1.5,2.5]_{simid},[2.5,3.5]_{tanh},\{3.5,4.5\}_{elu},\{4. 5,5.5\}_{relu},\) and \([5.5,6.5]_{selu}\}\) and \(\{[0.5,6.5]\}\). \([0.5,1.5]_{linear}\) denotes the search range for the linear function. The meaning of other intervals is similar to this meaning. The range \([0.5,6.5]\) denotes the entire search range of the activation function. Obviously, all the candidate values have the same intervals.