## 3 Methodology
### Feature Selection  
The extracted features include many noisy and irrelevant features. Using those features directly may result in poor classification. Selecting the discriminant features prior to classification is of paramount importance in supervised machine learning methods. The algorithm used for feature selection was a PSO algorithm--a population-based metaheuristic method, inspired by bird flocking or fish swarming, first described by [PERSON] and [PERSON] [51]. It has been successfully used in global search problems. It is easy to implement, the computation time is reasonable and provides the global search. A PSO flowchart is illustrated in Figure 7. In PSO, each particle has three attributes: position, velocity, and fitness. The position of each particle is a potential solution. The fitness determines the movement of each particle.  
Figure 6: Visualization of features maps in pool1, pool2 and pool3 from DenseNet.  
Let denote that the population of \(n\) particles is \(X=[X_{1},\ X_{2},\ \ldots X_{n}]\) in the potential solution in a \(D\)-dimensional space. The position, \(X_{i}\), and velocity, V\({}_{i}\), of particle, \(i\), are:  
\[X_{i}=\ [x_{i1},\ x_{i2},\ \ldots\,\ x_{iD}] \tag{1}\]  
\[V_{i}=\ [v_{i1},\ v_{i2},\ \ldots\,\ v_{iD}] \tag{2}\]  
The particles move through the solution space, and their fitness values are evaluated. The direction and distance of the particle movement is determined by the velocity. The personal best position of each particle and the global best position among all particles are tracked to update individual positions. The personal best position means the best position and fitness found for particle, \(i\): \(\textit{Pbest}_{i}=[p_{i1},\ p_{i2},\ \ldots\,\ p_{iD}]\). The global best position, \(\textit{Gbest}\), is the best position and fitness for all particles in the swarm. The velocity and position of the particle are updated:  
\[v_{id}^{t+1}=\omega v_{id}^{t}+c_{1}r_{1}\Big{(}p_{id}^{t}-x_{id}^{t}\Big{)} +c_{2}r_{2}\Big{(}\textit{Gbest}-x_{id}^{t}\Big{)},\ d\ =\ 1,2,\ldots,D \tag{3}\]  
\[x_{id}^{t+1}=x_{id}^{t}+v_{id}^{t+1},\ d\ =\ 1,2,\ldots,D;\ i\ =\ 1,2,\ldots n \tag{4}\]  
where \(t\) is the current iteration index, \(\omega\) denotes an inertia weight, \(c_{1}\) and \(c_{2}\) are acceleration coefficients, and \(r_{1}\) and \(r_{2}\). are random numbers between 0 and 1.  
The features are encoded as the particle swarm here. Pseudocode for feature selection using PSO is given in Algorithm 1. We input the training dataset, the population size, the maximum number of iteration, and objective function. First, particles positions and velocities were randomly initialized and the fitness of each particle was computed using the objective function. The particle with the highest fitness value are considered as the best particle and so, its feature elements will be selected. As our main purpose of optimization is to obtain the higher classification accuracy, we directly used the value of the classification accuracy as the fitness value. The personal and global best positions are tracked to iteratively update the position and velocity of each particle and find the best set of features until a satisfactory fitness or the maximum number of iterations is reached.  
Figure 7: Particle swarm optimization (PSO) flowchart.