Email spam as you know; initially looking harmless, those endless get rich quickly scams and false lottery wins could seem benign. Behind the scenes, however, spam is a real pain for both companies and people. It wastes money, clogs inboxes, and more dangerously can slip in phishing attempts or malware. Researchers have tried everything from simple keyword filters to some rather sophisticated artificial intelligence over the years in an attempt to fight it. The truth is, though, spammers are smart. Your filter\'s degree of predictability will determine how quickly they can evade it. This study helps with this. Rather than depending only on one type of model, such as a CNN or a simple LSTM, we chose to vary things and produce a hybrid deep learning system. CNNs are excellent at identifying small patterns in text, BiLSTMs help understand the whole context of a message (what came before and after), and then, just for that extra punch, we brought in Reinforcement Learning to let the model actually learn from its own mistakes over time. Think of it like assembling a team where each player brings a special ability. Still, we did not stop there, not even near. In the last section of this work and this is the bit I\'m most proud of we developed a custom reward-based attention mechanism that changes which parts of an email receive more focus based on whether the model obtained the previous predictions right or wrong. It\'s sort of like teaching the model to \"pay more attention next time,\" based on past behavior: a bit like how we humans learn following a mistake. I built everything to run on Google Colab with live demos, tested the model on a mix of standard and hybrid datasets, and ensured the architecture is lightweight enough for practical use. So the outcome is Not only does this system know how to adapt but it also catches spam better than many current systems. And that might just be the secret to remain ahead in a world where spam keeps changing its strategies.
Introduction
Spam emails remain a persistent digital threat, evolving from simple junk to sophisticated phishing, malware, and identity theft vectors. Traditional spam filters—rule-based or classical ML—are inadequate against today's AI-powered, context-aware spam tactics.
???? Proposed Solution
The paper introduces a hybrid deep learning model for spam detection that combines:
CNN for detecting local spam patterns (e.g., spammy phrases),
BiLSTM for capturing semantic and contextual flow in both directions,
Reinforcement Learning (RL)-based attention to dynamically focus on important features and adapt over time.
This model is designed to be:
Lightweight and edge-compatible, usable on common platforms like Google Colab
Transparent and accessible, unlike closed-source filters (e.g., Gmail’s)
Adaptive, learning from misclassifications via an RL feedback loop
???? Research Methodology
A dual-pronged approach was used:
Theoretical Review: Analyzed over 50 peer-reviewed papers (2015–2024) on spam detection and deep learning methods.
Practical Implementation: Developed and tested a hybrid model using TensorFlow/Keras on:
SpamAssassin
Enron Spam Dataset
A custom hybrid dataset to reflect real-world spam
Key evaluation metrics:
Accuracy, Precision, Recall, F1-score
Generalization across datasets
Efficiency and lightweight deployment feasibility
???? Model Architecture
A multi-stage architecture combining the strengths of three key components:
Component
Functionality
CNN Layer
Detects local patterns and phrases commonly used in spam
BiLSTM Layer
Captures context and sequential meaning from both directions
RL-Based Attention
Focuses dynamically on important features using a reward mechanism
Dense + Softmax Layer
Final classification between spam (1) and ham (0)
Input: Preprocessed padded sequences using FastText embeddings
Output: Real-time spam classification with improved adaptability
???? Preprocessing & Dataset Details
Cleaning: Removed HTML, headers, symbols
Tokenization: Transformed into word sequences
Stemming, stopword removal, and padding for consistent input
Dataset Name
Total Emails
Spam
Ham
Source
SpamAssassin
6,047
1,813
4,234
Public sources
Enron Email Dataset
35,716
17,165
18,551
Tagged Enron emails
Custom Hybrid Dataset
10,000
5,100
4,900
Mixed, realistic spam traits
?? Training Details
Train/Test Split: 80/20 with a 10% validation subset
Hardware: Google Colab with NVIDIA T4 GPU (16GB RAM)
High accuracy across all datasets, with strong generalization ability
Low false positive rate, especially on borderline or ambiguous emails
Adaptability: RL-attention layer improved long-term performance by learning from feedback
Lightweight enough for real-time or edge-based use
???? Key Contributions
Hybrid Multi-Stage Architecture: Merges CNN + BiLSTM + RL in one model
RL-Based Adaptive Attention: More flexible than fixed or learned attention
Reward-Based Feature Weighting: Model refocuses based on classification feedback
Cross-Dataset Evaluation: Ensures robustness across spam types and sources
???? Research Gaps Addressed
Static spam models with no adaptability
Lack of reinforcement learning use in spam detection
Poor generalization and explainability
Absence of lightweight, real-time, or online learning approaches
???? Motivation
Modern spam emails mimic real human language and change tactics quickly. Current models:
Struggle with real-time adaptability
Lack semantic awareness
Can’t evolve with new spam trends
This project aims to develop a flexible, explainable, and intelligent spam filter that adapts over time, works on low-resource devices, and can be improved or extended by developers.
Conclusion
Email spam is a major and increasing threat to digital trust, user productivity, and communication security, not only a daily irritability. Scholars have addressed it over years with everything from robust machine learning algorithms to rule-based filters. But spam is always changing, becoming more clever and flexible. Our detecting systems must thus also change. We presented in this work a hybrid deep learning model combining Reinforcement Learning, CNN, and BiLSTM strengths.
Every component of the model is important: CNNs identify repeating spammy patterns, BiLSTMs grasp the larger background of a message, and the RL component lets the model dynamically change its attention using feedback. We evaluated this architecture on several datasets-SpamAssassin, Enron, and a custom hybrid dataset among others. The model exceeded many strong baselines including advanced neural networks like HAN, Naive Bayes, and even SVMs. Especially, it attained 98.1% accuracy and greatly lowered false positives, a common weak point of many spam filters. The adaptive learning capacity of the model is the true novelty here, not only performance.
Reinforcement learning helps the system learn not once but rather how to improve itself depending on what works and what doesn\'t. That allows self-evolving email filters which improve with increasing usage to open doors. Still, we have admitted a few constraints: the computational cost of deep layers and the need of multilingual support. We have also discussed future directions to address those including online learning, TinyML deployment, and transformer-based attention. This work is a step toward smarter spam detection: systems that not only identify but also grow, learn, and adapt alongside the threats they are trying to stop.
References
[1] Z. Hassani, V. Hajihashemi, K. Borna, and I. S. Dehmajnoonie, “A Classification Method for E-mail Spam Using a Hybrid Approach for Feature Selection Optimization,” Journal of Sciences, Islamic Republic of Iran, vol. 31, no. 2, pp. 165–173, 2020.
[2] M. Awad and M. Foqaha, “Email Spam Classification Using Hybrid Approach of RBF Neural Network and Particle Swarm Optimization,” International Journal of Network Security & Its Applications (IJNSA), vol. 8, no. 4, pp. 17–29, Jul. 2016.
[3] E. John-Africa and V. T. Emmah, “Performance Evaluation of LSTM and RNN Models in the Detection of Email Spam Messages,” European Journal of Information Technologies and Computer Science, vol. 2, no. 6, pp. 24–27, 2022, doi: 10.24018/ejcompute.2022.2.6.80.
[4] M. Qasaimeh, Y. A. Yaseen, R. Al-Qassas, and M. A. Al-Fayoumi, “Email Fraud Attack Detection Using Hybrid Machine Learning Approach,” Recent Patents on Computer Science, Jun. 2019, doi:10.2174/2213275912666190617162707.
[5] A. Idris and A. Selamat, “Combining Negative Selection Algorithm with Particle Swarm Optimization for Email Spam Detection,” Applied Soft Computing, vol. 22, pp. 43–55, Sep. 2014.
[6] N. Parmar, A. Sharma, and A. K. Kadam, “Email Spam Detection Using Naïve Bayes and Particle Swarm Optimization,” International Journal of Engineering Research & Technology (IJERT), vol. 9, no. 3, Mar. 2020.
[7] T. Zavrak and F. Yilmaz, “An Effective Spam Mail Detection Method Based on Neural Networks,” International Journal of Intelligent Systems and Applications in Engineering, vol. 10, no. 2, pp. 206–212, 2022.
[8] Y. Liu, Y. Li, and C. Meng, “An Email Classification Model Based on CNN and BiLSTM,” Journal of Physics: Conference Series, vol. 1827, no. 1, p. 012029, 2021, doi: 10.1088/1742-6596/1827/1/012029.
[9] K. Patel and M. S. Rani, \"Investigating resource allocation techniques and key performance indicators (KPIs) for 5G new radio networks: A review,\" Int. J. Comput. Netw. Appl., 2023.
[10] S. Ahmed and N. Raza, \"Secure and compatible integration of cloud-based ERP solution: A review,\" Int. J. Intell. Syst. Appl. Eng., vol. 11, no. 9s, pp. 695–707, 2023.
[11] V. Kumar and D. S. Mishra, \"Ensemble learning based malicious node detection in SDN based VANETs,\" J. Inf. Syst. Eng. Bus. Intell., vol. 9, no. 2, Oct. 2023.
[12] M. Shaikh and S. Jain, \"Security in enterprise resource planning solution,\" Int. J. Intell. Syst. Appl. Eng., vol. 12, no. 4s, pp. 702–709, 2024.
[13] N. Thakur and A. B. Singh, \"Secure and compatible integration of cloud-based ERP solution,\" J. Army Eng. Univ. PLA, vol. 23, no. 1, pp. 183–189, 2023.