# An Effective Ensemble Approach for Preventing and Detecting Phishing Attacks in Textual Form
## 4 Experiments and Results
### Selection of Base Learners
#### 4.3.1 Method 1 (Weighted Ensemble)  
In typical machine learning scenarios, equal treatment is given to each class during the training process. The objective of the model is to minimize a loss function that takes into account the performance across all classes. When there is a class imbalance, the assignment of different weights to each class helps to address this issue. The intention is to provide greater significance to the minority class by increasing its weight and, consequently, the contribution of its samples to the overall loss function. The class weights are integrated into the loss function utilized during training. The loss for each example is multiplied by its corresponding class weight. Consequently, errors in the minority class have a greater impact on the overall loss, guiding the model to prioritize accurate prediction of the minority class. Figure 7 presents how we used class weights to improve class imbalance. * Setting Class Weights: The determination of class weights is necessary to address the imbalance present in the dataset. It is customary for the weight assigned to each class to be inversely proportional to its frequency. Equation (9) is the formula for class weight:  
Figure 6: ROC Curve for Neural Network. Figure 7: Weighted ensemble classifier\[w_{i}=\frac{N}{\text{num\_samples\_class\_i}} \tag{9}\]  
where \(N\) represents the total number of samples in the dataset, and num_samples_class_i is the number of samples belonging to class \(i\). * Incorporating Class Weights: One approach to incorporating class weights into the training process is by modifying the loss function. Common loss functions, including cross-entropy, can be adjusted to accommodate the influence of class weights. A practical example of this can be seen in binary classification, where the weighted cross-entropy loss for an individual sample can be computed as follows (10): \[L(y,\hat{y})=-w_{\text{pos}}\cdot y\cdot\log(\hat{y})-w_{\text{neg}}\cdot(1-y) \cdot\log(1-\hat{y})\] (10) where \(y\) is the true label (0 or 1), \(\log(\hat{y})\) is the predicted probability, and \(w_{\text{pos}}\) and \(w_{\text{neg}}\) are the weights for the positive and negative classes, respectively. * Implementation in Machine Learning Frameworks. During the process of model evaluation, we employed a Python script within the AZURE computing environment. Upon completion of the training phase, it becomes of utmost importance to evaluate the performance of the model by utilizing widely accepted metrics such as precision, recall, F1 score, or the area under the receiver operating characteristic curve (AUC-ROC). The results for the first ensemble classification method are presented in Table 4.  
As we can see in Figure 8, method 1 demonstrates an F1-score of 0.9, a value that is competitive and close to that of the best-performing individual classifier (BDT, which exhibits an F1-score of 0.905). This observation suggests that the ensemble method efficiently captures both precision and recall, thereby achieving a favorable equilibrium between false positives and false negatives. The precision of Method 1 (0.91) is marginally lower than some individual classifiers, such as BPM (0.975) and NN (0.96). Nevertheless, the disparity is not significant, and the ensemble approach still maintains a high level of precision. Method 1 harnesses the power of an ensemble of classifiers, thereby potentially minimizing overfitting and effectively capturing diverse patterns within the data. Consequently, it tends to possess greater robustness and generalizability when confronted with unseen examples, contributing to its efficacy in detecting instances of phishing. The significance of higher precision or recall may vary depending on the specific requirements. Method 1 appears to strike a commendable balance between the two performance measures.