# amritkaur15/sentiment-classifier architecture

> Architecture diagram of the GitHub repository amritkaur15/sentiment-classifier, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amritkaur15/sentiment-classifier
- Repository: https://github.com/amritkaur15/sentiment-classifier

## Overview

1. **Repository shape**
   - This is a small, notebook-driven machine learning project, not an application with multiple services.
   - The architecture is centered on one Jupyter notebook, one labeled dataset, and a few generated analysis artifacts.

2. **Primary entry point**
   - `sentiment_classifier.ipynb` is the main workflow.
   - It likely contains the full pipeline: data loading, text cleaning, feature extraction, model training, evaluation, and inspection of the most influential words.

3. **Data source**
   - `IMDB Dataset.csv` is the core input asset.
   - It provides the labeled text examples used to train and test the classifier, so the dataset is the main boundary between raw data and the modeling pipeline.

4. **Modeling pipeline**
   - The README states the model uses **TF-IDF + Logistic Regression** via scikit-learn.
   - Architecturally, this means text is converted into sparse numeric features first, then a linear classifier learns sentiment boundaries from those features.

5. **Text processing boundary**
   - The project likely includes standard preprocessing in the notebook, but the key architectural point is that all text handling remains inside the notebook workflow.
   - There is no separate preprocessing service, API, or batch job; the notebook owns the full transformation path from raw review text to model-ready vectors.

6. **Training and evaluation flow**
   - The training flow is: load CSV → split data → vectorize text with TF-IDF → fit logistic regression → evaluate on held-out data.
   - The evaluation output is summarized as accuracy and a confusion matrix, which are the main quality checkpoints for the classifier.

7. **Model interpretability**
   - The “Top Predictive Words” section indicates the notebook extracts feature weights from the linear model.
   - This is an important architectural advantage of logistic regression: the model can be inspected directly to identify positive and negative sentiment indicators.

8. **Generated artifacts**
   - `confusion_matrix.png` is referenced in the README as a generated output, even though it is not shown in the file tree.
   - This suggests the notebook produces visual reporting artifacts alongside the trained model results, but likely does not persist a reusable model file in the repository.

9. **Runtime and tooling**
   - The project depends on Python 3.11 and common scientific Python libraries: pandas, numpy, scikit-learn, matplotlib, and Jupyter.
   - `requirements.txt` exists to capture these dependencies, while the README provides manual setup steps for an interactive notebook environment.

10. **Operational model**
    - The repository is intended for interactive, local execution rather than deployment.
    - There is no evidence of a serving layer, database, message queue, or cloud infrastructure; the notebook is the entire execution environment.

11. **Architectural boundary summary**
    - Input boundary: labeled IMDB reviews from CSV.
    - Processing boundary: TF-IDF feature generation and logistic regression training inside the notebook.
    - Output boundary: evaluation metrics, confusion matrix image, and ranked sentiment-bearing words.

12. **What to draw in an architecture diagram**
    - A simple left-to-right flow is appropriate: dataset file → notebook pipeline → trained classifier/evaluation outputs.
    - The only significant external dependency is the Python/scikit-learn/Jupyter runtime; everything else is local and self-contained.

Main entry points: [`sentiment_classifier.ipynb`](https://github.com/amritkaur15/sentiment-classifier/blob/main/sentiment_classifier.ipynb) (Notebook), [`IMDB Dataset.csv`](https://github.com/amritkaur15/sentiment-classifier/blob/HEAD/IMDB%20Dataset.csv) (IMDB Dataset.csv)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_dataset[("IMDB Dataset.csv<br/>labeled text data<br/>[IMDB Dataset.csv]")]
node_notebook["Notebook"]
node_prep["Text prep<br/>cleaning stage"]
node_tfidf["TF-IDF<br/>feature extraction"]
node_model{{"Logistic regression<br/>linear classifier"}}
node_eval["Evaluation<br/>metrics + plots"]
node_words["Top words<br/>interpretability"]

node_dataset -->|"loaded by"| node_notebook
node_notebook -->|"runs"| node_prep
node_prep -->|"transforms to"| node_tfidf
node_tfidf -->|"trains"| node_model
node_model -->|"scores"| node_eval
node_model -->|"explains"| node_words
node_eval -->|"reported in"| node_notebook
node_words -->|"reported in"| node_notebook

click node_dataset "https://github.com/amritkaur15/sentiment-classifier/blob/main/IMDB Dataset.csv"
click node_notebook "https://github.com/amritkaur15/sentiment-classifier/blob/main/sentiment_classifier.ipynb"
click node_prep "https://github.com/amritkaur15/sentiment-classifier/blob/main/sentiment_classifier.ipynb"
click node_tfidf "https://github.com/amritkaur15/sentiment-classifier/blob/main/sentiment_classifier.ipynb"
click node_model "https://github.com/amritkaur15/sentiment-classifier/blob/main/sentiment_classifier.ipynb"
click node_eval "https://github.com/amritkaur15/sentiment-classifier/blob/main/sentiment_classifier.ipynb"
click node_words "https://github.com/amritkaur15/sentiment-classifier/blob/main/sentiment_classifier.ipynb"

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_notebook,node_prep,node_tfidf,node_model,node_eval,node_words toneNeutral
```

## Components

### Other components

- [IMDB Dataset.csv](https://github.com/amritkaur15/sentiment-classifier/blob/HEAD/IMDB%20Dataset.csv): labeled text data · Core input corpus of reviews and sentiment labels. · `IMDB Dataset.csv`
- [Notebook](https://github.com/amritkaur15/sentiment-classifier/blob/main/sentiment_classifier.ipynb): workflow notebook · Main interactive pipeline that owns loading, preprocessing, training, and inspection. · `sentiment_classifier.ipynb`
- [Text prep](https://github.com/amritkaur15/sentiment-classifier/blob/main/sentiment_classifier.ipynb): cleaning stage · Notebook-internal text normalization and train/test split before feature extraction. · `sentiment_classifier.ipynb`
- [TF-IDF](https://github.com/amritkaur15/sentiment-classifier/blob/main/sentiment_classifier.ipynb): feature extraction · Converts reviews into sparse numerical vectors for linear modeling. · `sentiment_classifier.ipynb`
- [Logistic regression](https://github.com/amritkaur15/sentiment-classifier/blob/main/sentiment_classifier.ipynb): linear classifier · Learns the sentiment decision boundary from TF-IDF features. · `sentiment_classifier.ipynb`
- [Evaluation](https://github.com/amritkaur15/sentiment-classifier/blob/main/sentiment_classifier.ipynb): metrics + plots · Produces accuracy, confusion matrix, and other quality checks from held-out predictions. · `sentiment_classifier.ipynb`
- [Top words](https://github.com/amritkaur15/sentiment-classifier/blob/main/sentiment_classifier.ipynb): interpretability · Extracts influential positive and negative terms from model coefficients. · `sentiment_classifier.ipynb`

## Connections

- IMDB Dataset.csv → Notebook: loaded by · CSV reviews and labels are read into the notebook workflow.
- Notebook → Text prep: runs · The notebook performs preprocessing and splitting steps.
- Text prep → TF-IDF: transforms to · Cleaned text is vectorized into sparse features.
- TF-IDF → Logistic regression: trains · TF-IDF vectors feed the sentiment classifier.
- Logistic regression → Evaluation: scores · Predictions are evaluated on held-out data.
- Logistic regression → Top words: explains · Model weights are inspected to surface predictive words.
- Evaluation → Notebook: reported in · Metrics and confusion matrix are presented in the notebook.
- Top words → Notebook: reported in · Top words analysis is displayed in the notebook.
