Spaces:
Sleeping
Download README.md from RebKip/Spam_Detection_LSTM: direct link, hf CLI and curl.
- Browser
- Download file 3.53 kB
-
https://huggingface.co/spaces/RebKip/Spam_Detection_LSTM/resolve/main/README.md
- Command line
-
hf download hf://spaces/RebKip/Spam_Detection_LSTM/README.md
-
curl -L -o README.md https://huggingface.co/spaces/RebKip/Spam_Detection_LSTM/resolve/main/README.md
title: Spam Detection LSTM
emoji: π«
colorFrom: red
colorTo: red
sdk: docker
app_file: src/streamlit_app.py
app_port: 8501
tags:
- streamlit
pinned: false
short_description: AI-powered Spam vs. Ham classifier built with an LSTM RNN
license: mit
description: >-
AI-powered Spam vs. Ham classifier built with an LSTM Recurrent Neural Network
and Streamlit.
π« LSTM Spam Email & SMS Detector
An interactive, production-ready web application that utilizes a Long Short-Term Memory (LSTM) recurrent neural network to classify text messages as Spam or Ham (Legitimate).
This project demonstrates an end-to-end Machine Learning pipeline: from raw text preprocessing and tokenization to model training, evaluation calibration, and containerized deployment via Docker.
π Interactive Demo
- Type or paste any suspicious message or email into the text area.
- Click Predict.
- The app will return a classification badge (SPAM or HAM) alongside the model's precise internal probability score.
π Model Performance & Calibration
During evaluation on the test split (1,032 samples), the model was calibrated to prioritize a High-Precision Strategy to minimize irritating False Positives (marking a critical legitimate email as spam).
Using an optimized decision threshold of 0.80, the model achieves the following metrics:
π Metrics Summary
- Accuracy: 97.67%
- Precision: 95.61% (High precision ensures safe filtering)
- Recall: 85.16%
- F1-Score: 90.08%
π Classification Report
precision recall f1-score support
Negative (0) 0.98 0.99 0.99 904
Positive (1) 0.96 0.85 0.90 128
accuracy 0.98 1032
macro avg 0.97 0.92 0.94 1032
weighted avg 0.98 0.98 0.98 1032
π§ Technical Architecture & Pipeline
- Text Preprocessing: User input strings are automatically normalized to lowercase and stripped of redundant structural padding characters.
- Tokenization: Text sequences are mapped to numerical vector keys using a pre-saved training vocabulary tokenizer (
spam_tokenizer.pickle). - Sequence Padding: Sequences are bound to a strict maximum token length of 50 using a
post-paddingstructure. - Deep Learning Model: A Keras/TensorFlow architecture utilizing dense Word Embedding layers followed by sequential LSTM memory layers to capture contextual long-term text dependencies.
π οΈ Tech Stack & Engineering Details
- Frontend UI: Streamlit
- Deep Learning Runtime: TensorFlow / Keras
- Data Processing: NumPy & Pandas
- Deployment Container: Docker (Python 3.13-slim optimized environment)
π Repository Directory Layout
βββ Dockerfile # Container building directives & environment exposure
βββ requirements.txt # Managed Python dependencies
βββ src/
βββ streamlit_app.py # Main UI dashboard and inference logic
βββ best_lstm_model.keras # Pre-trained network layers and model weights
βββ spam_tokenizer.pickle # Binary serialized vocabulary tokenizer asset
Welcome to Streamlit!
Edit /src/streamlit_app.py to customize this app to your heart's desire. :heart:
If you have any questions, checkout our documentation and community forums.