# Advancing Image Spam Detection: Evaluating Machine Learning Models Through Comparative Analysis
## VGG16
### Top-performing Models  
ResNet50, XGBoost, and Logistic Regression emerged as the most effective models, with ResNet50 leading both in performance and consistency. The high AUC and low variance values indicate that these models not only classified spam images correctly but also did so consistently across folds, making them suitable candidates for deployment in spam detection systems.  
\begin{table}
\begin{tabular}{l c c c c c c} \hline \hline \multirow{2}{*}{**Model**} & \multicolumn{3}{c}{**Spam**} & \multicolumn{3}{c}{**Non-Spam/Ham**} \\ \cline{2-7}  & **Precision** & **Recall** & **F1-Score** & **Precision** & **Recall** & **F1-Score** \\ \hline VGG16 & 0.77 & 0.97 & 0.85 & 0.97 & 0.76 & 0.86 \\ Logistic Regression & 0.84 & 0.88 & 0.86 & 0.89 & 0.86 & 0.88 \\ LightGBM & 0.80 & 0.83 & 0.82 & 0.85 & 0.83 & 0.84 \\ SVM & 0.81 & 0.85 & 0.83 & 0.87 & 0.83 & 0.85 \\ XGBoost & 0.91 & 0.93 & 0.92 & 0.94 & 0.92 & 0.93 \\ ResNet50 & 0.93 & 0.97 & 0.95 & 0.97 & 0.94 & 0.95 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Comparison of F1-score, precision and recall.  
VGG16 and SVM Observations  
While VGG16 is known for its success in image classification, its performance in grayscale image spam detection was significantly lower. However, the results improved considerably when RGB images and tuning techniques were applied. SVM achieved reasonable results but exhibited a tendency toward false negatives, indicating a need for further optimization.  
In summary, ResNet50 outperformed all other models, showing strong generalization and minimal variance. XGBoost and Logistic Regression also demonstrated robust and stable results. LightGBM and SVM performed moderately well. Future research could explore the real-time deployment of deep learning models and assess their scalability and robustness in dynamic spam detection environments.  
**Validation with Different Dataset**  
This study assessed the model performance using cross-data training to examine the models accuracy with unseen image-based spam. Later, this study used a different dataset from Kaggle which included 811 ham photos and 930 spam images to validate the model's performance [31]. The spam image dataset was preprocessed identically, resized and passed through the same pipeline. Importantly, the model was neither re-trained nor subjected to hyperparameter tuning on this external dataset. Instead, it was used strictly for inference to assess the model's robustness. The risk of the model overfitting to a single source of dataset was decreased by testing it on a different dataset. After evaluation, ResNet50 achieved an impressive 98% accuracy, reinforcing its effectiveness in spam image classification. Due to its superior accuracy, low variance, and consistent performance across datasets, ResNet50 stands out as the most reliable model for this task.  
The execution times recorded during inference varied across the models, reflecting differences in computational complexity. ResNet50 was relatively efficient for a deep learning model, completing inference in 38 s. XGBoost followed with a time of 48 s, benefiting from its optimized tree-based structure. LightGBM and SVM demonstrated similar performance, both completing in 50 s. VGG16 and Logistic Regression each required 54 s, with the latter being unexpectedly slower due to preprocessing overhead. These results demonstrate that while multiple models achieved efficient performance, ResNet50 combines high accuracy, minimal execution time, and strong generalization, making it the most suitable candidate for image-based spam detection systems.