How wasifsohail5/spamshield works
Project type and purpose
• This is a machine-learning-powered web application (“Spam Shield”) for classifying emails as spam or ham.
• It consists of two logical pieces: an ML pipeline (data preprocessing, feature extraction, model training) and a real-time inference service (Streamlit app).
File structure
• Top-level scripts:
• Preprocessor.py – text cleaning & TF-IDF feature extraction
• app.py – Streamlit front-end for user input & model inference
• Spam E-Mail Detctor(ML).ipynb – Jupyter Notebook for experimentation & model training
• Model artifacts:
• vectorizer.joblib – serialized TF-IDF vectorizer
• rf_model.joblib, nb_model.joblib, spam_model.joblib – trained classifiers
• Config:
• requirements.txt – Python dependencies
• .devcontainer/ – dev-container config
• assets:
• screenshots/ – UI mockups
README for additional insights
• Three algorithms (Logistic Regression, Naïve Bayes, Random Forest) are trained offline, evaluated, and the best saved.
• Streamlit app loads the saved artifacts in real time.
• No external databases or cloud services—everything runs locally or on a single server/container.
Main components and interactions
a. Data Ingestion & Preprocessing (offline)
• Raw email dataset → Preprocessor.py / Notebook → cleaned tokens
• TF-IDF Vectorizer → vectorizer.joblib
b. Model Training & Evaluation (offline)
• Preprocessed features → train three models → evaluate → choose best → export .joblib
c. Model Repository
• vectorizer.joblib + best_model.joblib (spam_model.joblib) stored on disk
d. Streamlit Inference Service (app.py)
• User inputs email in browser → app loads vectorizer & model → transforms text → predicts spam/ham → displays result
e. Developer Environment
• .devcontainer for reproducible setup
Architectural patterns and design principles
• Separation of offline ML pipeline vs. online service
• Single responsibility: Preprocessing, Training, and Inference are separate modules
• Artifact repository on filesystem (could evolve into S3 or model registry)
• Stateless web app: no session or DB needed