How vamshidhar-reddy/efficient-spam-detection works
Project Type and Purpose
• This is a full-stack, Flask-based web application for Machine Learning inference. The purpose is to detect “spam” values coming from smart home appliances: users upload CSV data, the backend runs a pre-trained model, and the frontend displays predictions and performance metrics.
File Structure Analysis
• Top Level:
• Efficient_Spam_Detection.docx (design or requirements doc)
• README.md (project description)
• requirements.txt (Python dependencies)
• SOURCE_CODE/Efficient_Spam_Detection (application root)
• Within SOURCE_CODE/Efficient_Spam_Detection:
• app.py – Flask application entry point (routes, request handling).
• model/ – Jupyter notebooks, intermediate files, spam.pkl (the pickled ML model).
• static/ – CSS, JS, images (client assets).
• templates/ – HTML templates (Jinja2).
• test_data/ – sample CSVs for local testing.
• upload.csv – possibly a sample or placeholder for user uploads.
Architectural Patterns and Key Components
a. Presentation Layer (Frontend)
• Templates: index.html, upload.html, prediction.html, performance.html, chart.html, preview.html, login.html
• Static Assets: CSS (style.css, styles.css), JS (main.js), images and vendor assets
• Technology: HTML5, CSS3, JavaScript
b. Application Layer (Backend)
• Flask app (app.py) handling URL routes, form submissions, file uploads
• Controllers correspond to view functions in app.py
• Business logic: loading the spam.pkl model, preprocessing uploaded CSV via Pandas (implicit), running predictions
c. Data Layer
• Pre-trained ML model (spam.pkl) in two locations (model folder and root for fallback)
• Test CSV data (test_data/test.csv)
• Uploads stored temporarily (upload.csv)
d. ML Layer
• Jupyter notebooks (Untitled1.ipynb) represent the model training/prototyping stage
• Final spam.pkl used at runtime for inference
Relationships and Data Flow
1. User → Frontend: interacts with HTML forms (upload data, view charts)
2. Frontend → Backend: HTTP POST with CSV file or GET for pages
3. Backend (Flask)
• Receives CSV → invokes model loader → preprocesses data → runs prediction → sends results
• Renders templates or returns JSON for charts
4. Backend → ML Model: loads pickled classifier (spam.pkl) into memory at startup or on demand
5. Backend → Templates: injects prediction results, metrics
6. Frontend → User: displays predictions, performance charts
Architectural Patterns / Principles
• MVC-like separation:
• Model: spam.pkl + data preprocessing
• View: Jinja2 templates + static assets
• Controller: routes in app.py
• Single Python process serving both static and dynamic content (no microservices)
• Stateless inference: each request loads or reuses the pickled model