# ibrahimsharaf/doc2vec architecture

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

- Interactive diagram: https://gitdiagram.com/ibrahimsharaf/doc2vec
- Repository: https://github.com/ibrahimsharaf/doc2vec

## Overview

This repository is a Doc2Vec-based binary sentiment classifier for IMDB reviews. Running `text_classifier.py` loads the tab-separated dataset, splits and labels reviews, trains document embeddings and a logistic-regression classifier, then evaluates predictions with classification metrics. The graph separates data preparation, embedding, classification, and orchestration. The README describes the overall workflow; the sampled source shows the implementation. The `classifiers/` directory is empty in the provided tree, so no model persistence is shown.

Main entry points: [`text_classifier.py`](https://github.com/ibrahimsharaf/doc2vec/blob/master/text_classifier.py) (TextClassifier), [`models/classifier_model.py`](https://github.com/ibrahimsharaf/doc2vec/blob/master/models/classifier_model.py) (Logistic regression), [`models/doc2vec_model.py`](https://github.com/ibrahimsharaf/doc2vec/blob/master/models/doc2vec_model.py) (Doc2Vec model), [`models/model.py`](https://github.com/ibrahimsharaf/doc2vec/blob/master/models/model.py) (Model abstraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Workflow"]
  node_entry["Script entry point<br/>[text_classifier.py]"]
  node_orchestrator["TextClassifier<br/>[text_classifier.py]"]
  node_base_model["Model abstraction<br/>[model.py]"]
end

subgraph group_data["Review data"]
  node_preparation["Split and label<br/>[text_classifier.py]"]
  node_dataset["IMDB reviews<br/>[dataset.csv]"]
end

subgraph group_embedding["Document embeddings"]
  node_embedding_model["Doc2Vec model<br/>[doc2vec_model.py]"]
end

subgraph group_classification["Classification"]
  node_classifier_model["Logistic regression"]
  node_evaluation["Metrics evaluation"]
end

node_user(("User"))

node_user -->|"runs"| node_entry
node_entry -->|"creates"| node_orchestrator
node_entry -->|"starts"| node_orchestrator
node_orchestrator -->|"reads"| node_dataset
node_orchestrator -->|"splits and labels"| node_preparation
node_preparation -->|"labels reviews"| node_embedding_model
node_orchestrator -->|"initializes and trains"| node_embedding_model
node_orchestrator -->|"initializes and trains"| node_classifier_model
node_classifier_model -->|"gets vectors"| node_embedding_model
node_orchestrator -->|"tests model"| node_classifier_model
node_classifier_model -->|"gets test vectors"| node_embedding_model
node_classifier_model -->|"computes metrics"| node_evaluation
node_classifier_model -->|"extends"| node_base_model
node_embedding_model -->|"extends"| node_base_model

click node_entry "https://github.com/ibrahimsharaf/doc2vec/blob/master/text_classifier.py"
click node_orchestrator "https://github.com/ibrahimsharaf/doc2vec/blob/master/text_classifier.py"
click node_preparation "https://github.com/ibrahimsharaf/doc2vec/blob/master/text_classifier.py"
click node_dataset "https://github.com/ibrahimsharaf/doc2vec/blob/master/data/dataset.csv"
click node_embedding_model "https://github.com/ibrahimsharaf/doc2vec/blob/master/models/doc2vec_model.py"
click node_base_model "https://github.com/ibrahimsharaf/doc2vec/blob/master/models/model.py"
click node_classifier_model "https://github.com/ibrahimsharaf/doc2vec/blob/master/models/classifier_model.py"
click node_evaluation "https://github.com/ibrahimsharaf/doc2vec/blob/master/models/classifier_model.py"

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_entry,node_orchestrator,node_base_model,node_user toneBlue
class node_preparation,node_dataset toneAmber
class node_embedding_model toneMint
class node_classifier_model,node_evaluation toneRose
```

## Components

### Workflow

- [Script entry point](https://github.com/ibrahimsharaf/doc2vec/blob/master/text_classifier.py): `text_classifier.py`
- [TextClassifier](https://github.com/ibrahimsharaf/doc2vec/blob/master/text_classifier.py): `text_classifier.py`
- [Model abstraction](https://github.com/ibrahimsharaf/doc2vec/blob/master/models/model.py): `models/model.py`

### Review data

- [Split and label](https://github.com/ibrahimsharaf/doc2vec/blob/master/text_classifier.py): `text_classifier.py`
- [IMDB reviews](https://github.com/ibrahimsharaf/doc2vec/blob/master/data/dataset.csv): `data/dataset.csv`

### Document embeddings

- [Doc2Vec model](https://github.com/ibrahimsharaf/doc2vec/blob/master/models/doc2vec_model.py): `models/doc2vec_model.py`

### Classification

- [Logistic regression](https://github.com/ibrahimsharaf/doc2vec/blob/master/models/classifier_model.py): `models/classifier_model.py`
- [Metrics evaluation](https://github.com/ibrahimsharaf/doc2vec/blob/master/models/classifier_model.py): `models/classifier_model.py`

### Other components

- **User**

## Connections

- User → Script entry point: runs
- Script entry point → TextClassifier: creates
- Script entry point → TextClassifier: starts
- TextClassifier → IMDB reviews: reads
- TextClassifier → Split and label: splits and labels
- Split and label → Doc2Vec model: labels reviews
- TextClassifier → Doc2Vec model: initializes and trains
- TextClassifier → Logistic regression: initializes and trains
- Logistic regression → Doc2Vec model: gets vectors
- TextClassifier → Logistic regression: tests model
- Logistic regression → Doc2Vec model: gets test vectors
- Logistic regression → Metrics evaluation: computes metrics
- Logistic regression → Model abstraction: extends
- Doc2Vec model → Model abstraction: extends
