A deep learning spam classifier using LSTM neural network trained on a balanced email dataset.
- Test Accuracy: 94%
- Balanced dataset (equal spam/ham samples via downsampling)
- Early stopping to prevent overfitting
Python, TensorFlow, Keras, NLTK, NumPy, Pandas, Matplotlib
- Preprocessing — removes punctuation, strips stop words, tokenises text
- Balancing — downsamples ham emails to match spam count
- Model — Embedding → LSTM → Dense → Sigmoid
- Training — Adam optimizer, EarlyStopping + ReduceLROnPlateau callbacks
Embedding → LSTM(16) → Dense(32, relu) → Dense(1, sigmoid)
predict("Congratulations! You won a free iPhone!") # → 'spam'
predict("Hey, are we still meeting at 5pm?") # → 'ham'- Clone the repo
- Open
Detecting_Spam_Emails_Using_Tensorflow.ipynbin Colab or Jupyter - Run all cells (Runtime → Run all)