# shivammitra/spam-ham-project-using-word-2vec architecture

> Architecture diagram of the GitHub repository shivammitra/spam-ham-project-using-word-2vec, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shivammitra/spam-ham-project-using-word-2vec
- Repository: https://github.com/shivammitra/spam-ham-project-using-word-2vec

## Overview

#### Purpose and execution model
This is a notebook-driven Python ML project for binary SMS/message classification: spam versus ham. Its sole implementation entry point is `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`; users launch Jupyter and execute notebook cells sequentially. There is no packaged application, service, CLI, or deployment layer.

#### Pipeline orchestration
The notebook owns the complete experiment lifecycle: dataset loading, text transformation, embedding creation, feature aggregation, classifier training, and evaluation. Cell ordering is the primary control-flow contract, so later model stages depend on in-memory artifacts produced by earlier cells.
- `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`

#### Text preprocessing boundary
Raw message text is converted into normalized token sequences through lowercasing, tokenization, stopword/non-English-word removal, and lemmatization. This stage isolates NLP cleanup from downstream vectorization and depends on NLTK language resources.
- `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`

#### Embedding model stage
Gensim Word2Vec is trained on the processed corpus or replaced with loaded pretrained embeddings. Its output is a vocabulary-to-dense-vector mapping; tokens missing from that vocabulary must be handled at the embedding boundary before classifier features can be formed.
- `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`

#### Sentence feature construction
Each message’s variable-length token list is transformed into a fixed-size feature vector by averaging its available word embeddings (“Average Word2Vec”). This is the central representation boundary between unsupervised embedding generation and supervised classification.
- `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`

#### Supervised classification and evaluation
Fixed-size message vectors and spam/ham labels feed scikit-learn classifiers, including Naive Bayes, SVM, and Random Forest. The notebook evaluates predictions with accuracy, precision, recall, F1 score, and a confusion matrix, enabling comparison between candidate classifiers.
- `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`

#### Runtime and dependencies
The runtime is Python in Jupyter Notebook. Core libraries are pandas/numpy for tabular and numerical data, NLTK for preprocessing, Gensim for Word2Vec, and scikit-learn for model training and metrics. Required NLTK datasets (`punkt`, `stopwords`, `wordnet`) are external downloadable resources. Repository metadata and licensing are in `README.md` and `LICENSE`.

Main entry points: [`Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`](https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb) (Experiment Notebook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Notebook Runtime"]
  node_jupyter["Jupyter Notebook<br/>python runtime"]
  node_notebook["Experiment Notebook"]
end

subgraph group_pipeline["Experiment Pipeline"]
  node_dataset[("SMS Messages<br/>dataset")]
  node_nlkt_resources[("NLTK Resources<br/>external datasets")]
  node_preprocessing["Text Preprocessing<br/>NLP transform"]
  node_token_corpus["Processed Token Corpus<br/>in-memory corpus"]
  node_labels["Spam/Ham Labels<br/>target labels"]
end

subgraph group_models["Modeling"]
  node_word2vec["Word2Vec Training<br/>Gensim embedding"]
  node_pretrained["Pretrained Embeddings<br/>optional embedding source"]
  node_embedding_vocab["Embedding Vocabulary<br/>vector mapping"]
  node_avg_vectors["Average Word2Vec Features<br/>fixed-size features"]
  node_classifiers["Candidate Classifiers<br/>scikit-learn models"]
  node_evaluation["Evaluation Metrics<br/>model evaluation"]
end

node_user(("User<br/>actor"))
node_readme["Project Documentation<br/>README<br/>[README.md]"]
node_license["License"]

node_user -->|"launches"| node_jupyter
node_jupyter -->|"executes"| node_notebook
node_notebook -->|"loads"| node_dataset
node_dataset -->|"raw text"| node_preprocessing
node_nlkt_resources -->|"language data"| node_preprocessing
node_preprocessing -->|"normalized tokens"| node_token_corpus
node_token_corpus -->|"training corpus"| node_word2vec
node_word2vec -->|"trained vectors"| node_embedding_vocab
node_pretrained -.->|"alternative source"| node_embedding_vocab
node_token_corpus -->|"message tokens"| node_avg_vectors
node_embedding_vocab -->|"available embeddings"| node_avg_vectors
node_dataset -->|"extracts"| node_labels
node_avg_vectors -->|"feature matrix"| node_classifiers
node_labels -->|"training targets"| node_classifiers
node_classifiers -->|"predictions"| node_evaluation
node_labels -->|"ground truth"| node_evaluation
node_notebook -->|"reports"| node_evaluation

click node_jupyter "https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb"
click node_notebook "https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb"
click node_preprocessing "https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb"
click node_token_corpus "https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb"
click node_word2vec "https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb"
click node_pretrained "https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb"
click node_embedding_vocab "https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb"
click node_avg_vectors "https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb"
click node_labels "https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb"
click node_classifiers "https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb"
click node_evaluation "https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb"
click node_readme "https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/README.md"
click node_license "https://github.com/shivammitra/spam-ham-project-using-word-2vec/tree/main/LICENSE"

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_jupyter,node_notebook toneBlue
class node_dataset,node_nlkt_resources,node_preprocessing,node_token_corpus,node_labels toneAmber
class node_word2vec,node_pretrained,node_embedding_vocab,node_avg_vectors,node_classifiers,node_evaluation toneMint
class node_user,node_readme,node_license toneNeutral
```

## Components

### Notebook Runtime

- [Jupyter Notebook](https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb): python runtime · Executes the experiment cells sequentially. · `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`
- [Experiment Notebook](https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb): notebook · Owns the full SMS spam/ham workflow. · `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`

### Experiment Pipeline

Sequential notebook cells share in-memory artifacts.

- **SMS Messages**: dataset · Raw messages with spam/ham labels.
- **NLTK Resources**: external datasets · punkt, stopwords, and wordnet downloads.
- [Text Preprocessing](https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb): NLP transform · Normalizes, tokenizes, filters, and lemmatizes messages. · `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`
- [Processed Token Corpus](https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb): in-memory corpus · `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`
- [Spam/Ham Labels](https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb): target labels · `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`

### Modeling

- [Word2Vec Training](https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb): Gensim embedding · Builds token-to-dense-vector vocabulary. · `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`
- [Pretrained Embeddings](https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb): optional embedding source · Can replace locally trained Word2Vec vectors. · `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`
- [Embedding Vocabulary](https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb): vector mapping · Missing tokens are excluded before aggregation. · `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`
- [Average Word2Vec Features](https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb): fixed-size features · Averages available token embeddings per message. · `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`
- [Candidate Classifiers](https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb): scikit-learn models · Naive Bayes, SVM, and Random Forest. · `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`
- [Evaluation Metrics](https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/Spam%20Ham%20Projects%20Using%20Word2vec%2CAvgWord2vec.ipynb): model evaluation · Accuracy, precision, recall, F1, and confusion matrix. · `Spam Ham Projects Using Word2vec,AvgWord2vec.ipynb`

### Other components

- **User**: actor
- [Project Documentation](https://github.com/shivammitra/spam-ham-project-using-word-2vec/blob/main/README.md): README · `README.md`
- [License](https://github.com/shivammitra/spam-ham-project-using-word-2vec/tree/main/LICENSE): license · `LICENSE`

## Connections

- User → Jupyter Notebook: launches
- Jupyter Notebook → Experiment Notebook: executes
- Experiment Notebook → SMS Messages: loads
- SMS Messages → Text Preprocessing: raw text
- NLTK Resources → Text Preprocessing: language data
- Text Preprocessing → Processed Token Corpus: normalized tokens
- Processed Token Corpus → Word2Vec Training: training corpus
- Word2Vec Training → Embedding Vocabulary: trained vectors
- Pretrained Embeddings → Embedding Vocabulary: alternative source
- Processed Token Corpus → Average Word2Vec Features: message tokens
- Embedding Vocabulary → Average Word2Vec Features: available embeddings
- SMS Messages → Spam/Ham Labels: extracts
- Average Word2Vec Features → Candidate Classifiers: feature matrix
- Spam/Ham Labels → Candidate Classifiers: training targets
- Candidate Classifiers → Evaluation Metrics: predictions
- Spam/Ham Labels → Evaluation Metrics: ground truth
- Experiment Notebook → Evaluation Metrics: reports
