# irfan-farzand/spam-detection-ml architecture

> Architecture diagram of the GitHub repository irfan-farzand/spam-detection-ml, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/irfan-farzand/spam-detection-ml
- Repository: https://github.com/irfan-farzand/spam-detection-ml

## Overview

This repository is a notebook-based SMS spam-classification project, not a deployed messaging service. Its documented workflow runs from labeled data and message preprocessing through TF-IDF and Logistic Regression to prediction and evaluation; trained artifacts can be saved and reused. The graph reflects README documentation only: no source excerpts were available to verify notebook internals or finer-grained calls.

Main entry points: [`notebook/email_spam_predicition.ipynb`](https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb) (Logistic Regression), [`model/spam_model.pkl`](https://github.com/irfan-farzand/spam-detection-ml/blob/main/model/spam_model.pkl) (Trained classifier), [`model/tfidf_vectorizer.pkl`](https://github.com/irfan-farzand/spam-detection-ml/blob/main/model/tfidf_vectorizer.pkl) (Saved vectorizer), [`dataset/SMSSpamCollection`](https://github.com/irfan-farzand/spam-detection-ml/blob/main/dataset/SMSSpamCollection) (Labeled SMS data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_dataset[("Labeled SMS data")]
  node_preprocessing["Text preprocessing"]
  node_split["Train/test split"]
end

subgraph group_modeling["Classification"]
  node_tfidf["TF-IDF features"]
  node_classifier["Logistic Regression"]
  node_prediction["Spam or ham"]
end

subgraph group_evaluation["Evaluation"]
  node_evaluation["Model evaluation"]
  node_cross_validation["5-fold validation"]
end

subgraph group_artifacts["Saved artifacts"]
  node_saved_model["Trained classifier<br/>[spam_model.pkl]"]
  node_saved_vectorizer["Saved vectorizer"]
end

node_messages(("SMS messages"))

node_dataset -->|"loads for"| node_preprocessing
node_messages -->|"enters"| node_preprocessing
node_preprocessing -->|"prepares for"| node_split
node_split -->|"feeds"| node_tfidf
node_tfidf -->|"provides features"| node_classifier
node_classifier -->|"classifies"| node_prediction
node_classifier -->|"evaluated by"| node_evaluation
node_classifier -->|"validated by"| node_cross_validation
node_classifier -->|"saved as"| node_saved_model
node_tfidf -->|"saved as"| node_saved_vectorizer
node_saved_model -->|"reused for"| node_prediction
node_saved_vectorizer -->|"transforms input"| node_prediction

click node_dataset "https://github.com/irfan-farzand/spam-detection-ml/blob/main/dataset/SMSSpamCollection"
click node_preprocessing "https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb"
click node_split "https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb"
click node_tfidf "https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb"
click node_classifier "https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb"
click node_prediction "https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb"
click node_evaluation "https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb"
click node_cross_validation "https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb"
click node_saved_model "https://github.com/irfan-farzand/spam-detection-ml/blob/main/model/spam_model.pkl"
click node_saved_vectorizer "https://github.com/irfan-farzand/spam-detection-ml/blob/main/model/tfidf_vectorizer.pkl"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dataset,node_preprocessing,node_split toneBlue
class node_tfidf,node_classifier,node_prediction toneAmber
class node_evaluation,node_cross_validation toneMint
class node_saved_model,node_saved_vectorizer toneRose
class node_messages toneIndigo
```

## Components

### Data preparation

- [Labeled SMS data](https://github.com/irfan-farzand/spam-detection-ml/blob/main/dataset/SMSSpamCollection): `dataset/SMSSpamCollection`
- [Text preprocessing](https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb): `notebook/email_spam_predicition.ipynb`
- [Train/test split](https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb): `notebook/email_spam_predicition.ipynb`

### Classification

- [TF-IDF features](https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb): `notebook/email_spam_predicition.ipynb`
- [Logistic Regression](https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb): `notebook/email_spam_predicition.ipynb`
- [Spam or ham](https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb): `notebook/email_spam_predicition.ipynb`

### Evaluation

- [Model evaluation](https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb): `notebook/email_spam_predicition.ipynb`
- [5-fold validation](https://github.com/irfan-farzand/spam-detection-ml/blob/main/notebook/email_spam_predicition.ipynb): `notebook/email_spam_predicition.ipynb`

### Saved artifacts

- [Trained classifier](https://github.com/irfan-farzand/spam-detection-ml/blob/main/model/spam_model.pkl): `model/spam_model.pkl`
- [Saved vectorizer](https://github.com/irfan-farzand/spam-detection-ml/blob/main/model/tfidf_vectorizer.pkl): `model/tfidf_vectorizer.pkl`

### Other components

- **SMS messages**

## Connections

- Labeled SMS data → Text preprocessing: loads for (evidence: `README.md`)
- SMS messages → Text preprocessing: enters (evidence: `README.md`)
- Text preprocessing → Train/test split: prepares for (evidence: `README.md`)
- Train/test split → TF-IDF features: feeds (evidence: `README.md`)
- TF-IDF features → Logistic Regression: provides features (evidence: `README.md`)
- Logistic Regression → Spam or ham: classifies (evidence: `README.md`)
- Logistic Regression → Model evaluation: evaluated by (evidence: `README.md`)
- Logistic Regression → 5-fold validation: validated by (evidence: `README.md`)
- Logistic Regression → Trained classifier: saved as (evidence: `README.md`)
- TF-IDF features → Saved vectorizer: saved as (evidence: `README.md`)
- Trained classifier → Spam or ham: reused for (evidence: `README.md`)
- Saved vectorizer → Spam or ham: transforms input (evidence: `README.md`)
