# LSTM and Bat-Based RUSBoost Approach for Electricity Theft Detection
## 3 Proposed System Model
### Bat Algorithm  
Classification accuracy is normally improved through the parameter tunning of the model [32]. We use an optimization technique--the bat algorithm [33]--to choose the best parameter values for RUSBoost. The technique is inspired by the echolocation behavior of bats. During model validation, the hyper-parameters of RUSBoost are tuned to find the optimal values. The hyper-parameters are the learning rate, estimator and sampling strategy. The learning rate is the step size that adjusts the weights of each learner during training abd the estimator is the number of weak learners, which generates the final output.  
To find an optimum solution, the bats fly randomly at velocity \(v_{i}\), frequency \(f_{i}\) and loudness \(A_{i}\)[30]. They utilize an echo system to sense the distance from their prey and find the parameter values for the classifier. The range of frequency is set to [0, \(f_{max}\)] for simplicity. The high frequencies cover shorter distances and have shorter wavelengths. Depending on the targets, all the bats adjust their pulse rate in the range [0,1], where 0 means no pulse emission and 1 means the maximum rate of pulse emission.  
\(f_{i}\), \(v^{t}\) and \(x^{t}\) are the updated values of frequency, velocity and position, respectively. The updated \(f_{i}\), \(v^{t}\) and \(x^{t}\) are shown in Equations (9)-(11), which are mentioned in [34]:  
\[f_{i}=f_{min}+(f_{max}-f_{min})\beta, \tag{9}\]  
\begin{table}
\begin{tabular}{l l} \hline
**Hyper-Parameters** & **Values** \\ \hline Batch size & 50 \\ \hline Drop out & 0.2 \\ \hline Optimizer & Adam \\ \hline Epochs & 20 \\ \hline UNITS & 50 \\ \hline \end{tabular}
\end{table}
Table 4: Hyper-parameter values of LSTM.  
\[v_{i}^{t}=v_{i}^{t-1}+(x_{i}-x^{*})f_{i}, \tag{10}\]  
\[x_{i}^{t}=x_{i}^{t-1}+v_{i}^{t}. \tag{11}\]  
where \(\beta\) is a random number ranging between [0,1], while \(f_{min}\) is the minimum value of frequency and \(f_{max}\) is the maximum value of frequency. In Equation (10), \(x^{*}\) is the best solution in the current population and \(xi\) shows the position of a bat at the updated frequency \(f_{i}\). To find the local position, a solution is selected from the previous best position \(x_{i}^{t-1}\) and by the random flying of a bat at the updated velocity \(v_{i}^{t}\). The pseudo-code of the bat algorithm is given in Algorithm 1.  
```
1:Initialize bat population by \(X_{i}\) (\(i=1,2,3...n\))
2:Initialize velocity \(V_{i}\), loudness \(A_{i}\) and pulse rate \(r_{i}\)
3:Define the frequency \(f_{i}\), at position \(X_{i}\)
4:Maximum number of iterations is s, and t is the current iteration
5:while (\(t<s\))
6:Adjust the \(f_{i}\), \(v_{i}^{t}\) and \(x_{i}^{t}\) to find new solutions
7:Update the \(f_{i}\), \(v_{i}^{t}\) and \(x_{i}^{t}\) as given in Equations (9), (10) and (11)
8:if (rand\(\succ r_{i}\))
9:Choose the best solution
10:Find the local solution among the selected best solutions
11:endif
12:Go for new solution
13:if (rand\(<\)\(A_{i}\) and \(f_{i}\)\(<\)\(f_{*}\))
14:Select the solution
15:Change the loudness \(A_{i}\) and pulse rate \(r_{i}\)
16:endif
17:Rank the bats on the basis of minimum cost function
18:endif
19:Generate a final result
```  
**Algorithm 1** Bat algorithm.