# Detection of Malicious Websites Using Symbolic Classifier
## 2 Materials and Methods
### Over-Sampling Methods
#### 2.4.2 Adasyn  
The ADAptive SYNthetic (ADASYN) [31] algorithm is used to generate new synthetic data from the minority class. Before implementing the ADASYN algorithm a dataset with \(T\) samples is required. The dataset can be represented as \(\{x_{i},y_{i}\},i=1,\ldots,T\). where \(x_{i}\) represents an instance of n-dimensional feature space and \(y_{i}\) is a class label associated with \(x_{i}\). From the total number of samples \(S\) in the dataset the minority class samples \(S_{min}\) and majority classes \(T_{maj}\) samples are identified. The following rules apply for minority and majority class samples, i.e., the number of minority class samples must be lower than majority class samples (\(T_{min}\leq S_{maj}\) and the sum of minority and majority class samples must be equal to the total number of dataset samples \(T_{min}+T_{maj}=T\). This algorithm starts by calculating the ratio of minority to majority class and this is achieved using the equation:  
\[d=\frac{T_{min}}{T_{maj}}, \tag{1}\]  
where \(T_{min}\) and \(T_{maj}\) are the number of samples for minority and majority classes, respectively. The value of this ratio can be in the 0 to 1 range. The ratio is responsible for initializing the ADASYN algorithm which means that if the ratio value is very small or near 0 the algorithm will be initialized.  
After initialization, the ADASYN algorithm calculates the number of synthetic samples that have to be generated to balance the dataset which is done using the equation:  
\[G=\big{(}T_{maj}-T_{min}\big{)}\big{)}\beta. \tag{2}\]  
In Equation (2) the \(\beta\) parameter represents the desired balance level after synthetic data generation. This parameter is in the 0 to 1 range and if equal to 1 the dataset is perfectly balanced. In each neighborhood \(r_{i}\) of the minority sample the k-nearest neighbors must be found to calculate the dominance of the majority class which is done using the expression that can be written in the following form:  
\[r_{i}=\frac{N_{maj}}{k}. \tag{3}\]  
In Equation (3), the \(N_{maj}\) represents the number of majority samples surrounding the minority sample. The dominance of majority class \(r_{i}\) is in the range 0-1. The \(r_{i}\) is then normalized using the expression:  
\[\sum\hat{r}_{i}=\frac{r_{i}}{\sum_{i=1}^{T_{min}}}, \tag{4}\]  
where \(\hat{r}_{i}\) is the density distribution \(\sum_{i}\hat{r}_{i}=1\). The next step is to determine the number of synthetic samples that have to be generated for each minority sample using the expression:  
\[G_{i}=G\hat{r}_{i}, \tag{5}\]where \(G\) represents the total number of synthetic samples that have to be generated for the minority class. The number of synthetic data samples \(g_{i}\) that have to be generated for each minority class sample is done by randomly choosing one minority data sample \(x_{zi}\) from k nearest neighbors of \(x_{i}\) and generate synthetic data samples using the expression:  
\[s_{i}=x_{i}+(x_{zi}-x_{i})\times\lambda, \tag{6}\]  
where \((x_{zi}-x_{i})\) and \(\lambda\) represent the difference vector in n-dimensional space and randomly generated numbers in the 0 to 1 range, respectively.