# shreashi-saha/fake-news-detection-nlp architecture

> Architecture diagram of the GitHub repository shreashi-saha/fake-news-detection-nlp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shreashi-saha/fake-news-detection-nlp
- Repository: https://github.com/shreashi-saha/fake-news-detection-nlp

## Overview

This is a small, single-script fake-news classifier. It combines labeled real and fake article CSVs, cleans the text, trains a logistic-regression model, evaluates it, and prompts for an article to classify. The script also compares Naive Bayes and SVM models and plots evaluation results. All processing stages are implemented in main.py; the graph separates their responsibilities rather than implying separate modules. Evidence is limited to the provided main.py excerpt.

Main entry points: [`main.py`](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py) (Interactive prediction), [`Fake.csv`](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/Fake.csv) (Fake articles), [`True.csv`](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/True.csv) (Real articles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_fake_data["Fake articles<br/>[Fake.csv]"]
  node_real_data["Real articles<br/>[True.csv]"]
  node_load_combine["Load and label data<br/>[main.py]"]
  node_clean["Clean article text<br/>[main.py]"]
  node_split["Train/test split<br/>[main.py]"]
end

subgraph group_model["Classification"]
  node_tfidf["TF-IDF vectors<br/>[main.py]"]
  node_logistic["Logistic regression<br/>[main.py]"]
  node_comparisons["Model comparisons<br/>[main.py]"]
end

subgraph group_results["Evaluation and use"]
  node_evaluation["Metrics and plots<br/>[main.py]"]
  node_interactive["Interactive prediction<br/>[main.py]"]
  node_prediction["Fake/real label<br/>[main.py]"]
end

node_user(("Article submitter"))

node_load_combine -->|"reads"| node_fake_data
node_load_combine -->|"reads"| node_real_data
node_load_combine -->|"passes articles"| node_clean
node_clean -->|"passes cleaned text"| node_split
node_split -->|"fits and transforms"| node_tfidf
node_tfidf -->|"provides vectors"| node_logistic
node_logistic -->|"provides predictions"| node_evaluation
node_tfidf -->|"provides vectors"| node_comparisons
node_split -->|"provides labels"| node_comparisons
node_user -->|"enters article"| node_interactive
node_interactive -->|"cleans input"| node_clean
node_interactive -->|"transforms input"| node_tfidf
node_interactive -->|"requests prediction"| node_logistic
node_interactive -->|"returns label"| node_prediction
node_prediction -->|"prints result"| node_user

click node_fake_data "https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/Fake.csv"
click node_real_data "https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/True.csv"
click node_load_combine "https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py"
click node_clean "https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py"
click node_split "https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py"
click node_tfidf "https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py"
click node_logistic "https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py"
click node_comparisons "https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py"
click node_evaluation "https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py"
click node_interactive "https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py"
click node_prediction "https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.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_fake_data,node_real_data,node_load_combine,node_clean,node_split toneBlue
class node_tfidf,node_logistic,node_comparisons toneAmber
class node_evaluation,node_interactive,node_prediction toneMint
class node_user toneIndigo
```

## Components

### Data preparation

- [Fake articles](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/Fake.csv): `Fake.csv`
- [Real articles](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/True.csv): `True.csv`
- [Load and label data](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py): `main.py`
- [Clean article text](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py): `main.py`
- [Train/test split](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py): `main.py`

### Classification

- [TF-IDF vectors](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py): `main.py`
- [Logistic regression](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py): `main.py`
- [Model comparisons](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py): `main.py`

### Evaluation and use

- [Metrics and plots](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py): `main.py`
- [Interactive prediction](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py): `main.py`
- [Fake/real label](https://github.com/shreashi-saha/fake-news-detection-nlp/blob/master/main.py): `main.py`

### Other components

- **Article submitter**

## Connections

- Load and label data → Fake articles: reads (evidence: `main.py`)
- Load and label data → Real articles: reads (evidence: `main.py`)
- Load and label data → Clean article text: passes articles (evidence: `main.py`)
- Clean article text → Train/test split: passes cleaned text (evidence: `main.py`)
- Train/test split → TF-IDF vectors: fits and transforms (evidence: `main.py`)
- TF-IDF vectors → Logistic regression: provides vectors (evidence: `main.py`)
- Logistic regression → Metrics and plots: provides predictions (evidence: `main.py`)
- TF-IDF vectors → Model comparisons: provides vectors (evidence: `main.py`)
- Train/test split → Model comparisons: provides labels (evidence: `main.py`)
- Article submitter → Interactive prediction: enters article (evidence: `main.py`)
- Interactive prediction → Clean article text: cleans input (evidence: `main.py`)
- Interactive prediction → TF-IDF vectors: transforms input (evidence: `main.py`)
- Interactive prediction → Logistic regression: requests prediction (evidence: `main.py`)
- Interactive prediction → Fake/real label: returns label (evidence: `main.py`)
- Fake/real label → Article submitter: prints result (evidence: `main.py`)
