How farhann198/fake-news-detection works
1. Repository shape
- This is a small, notebook-driven machine learning project rather than a multi-module application.
- The main executable artifact is fake-news-detection.ipynb; the .ipynb_checkpoints copy is just a Jupyter autosave.
2. Primary inputs
- The project ships with two CSV datasets: True.csv and Fake - Fake.csv.
- These represent the two classification classes: real news and fake news.
- The README indicates the original source is Kaggle’s “Fake and Real News Dataset.”
3. Core workflow
- The notebook appears to implement a linear NLP classification pipeline:
data loading → text cleaning → feature extraction → model training → model comparison.
- This is an offline batch workflow, not a streaming or interactive inference service.
4. Text preprocessing boundary
- Raw article text is normalized before modeling.
- The README lists the cleaning steps: lowercasing, punctuation removal, URL removal, special-character removal, number removal, and extra-space trimming.
- This preprocessing boundary is important because every downstream model consumes the cleaned text, not the original articles.
5. Feature extraction layer
- The main representation step is TF-IDF vectorization with n-grams.
- The specific configuration noted in the README is TfidfVectorizer(ngram_range=(1,2)).
- This converts the text corpus into sparse numeric features used by all classifiers.
6. Modeling layer
- The project compares several standard scikit-learn classifiers:
Logistic Regression, Decision Tree, Random Forest, and Gradient Boosting.
- These models form the core “decision” subsystem and are trained on the same vectorized feature space for fair comparison.
7. Evaluation flow
- The notebook evaluates the models on processed data to compare classification performance.
- The README emphasizes accuracy comparison rather than deployment metrics, suggesting the goal is model benchmarking and selection.
- Any diagram should show evaluation branching after training, with multiple model paths converging into comparison.
8. Technology stack
- Python is the runtime.
- Pandas and NumPy support data handling, while scikit-learn provides preprocessing, vectorization, and classifiers.
- Jupyter Notebook is the execution environment and the main user interface for the project.
9. System boundaries
- All logic is contained locally in the notebook and CSV files; there is no API layer, database, or external inference endpoint.
- The Kaggle dataset source is the only external dependency mentioned, and it is used as an offline data source rather than a live integration.
10. Likely architecture diagram view
- A correct diagram would show: two labeled CSV inputs feeding a notebook pipeline, a preprocessing stage, a TF-IDF feature stage, four parallel classifier branches, and an evaluation/comparison output.
- The repository has no separate service boundaries, so the primary architectural separation is between data, text processing, feature engineering, and model comparison.
Main entry points: fake-news-detection.ipynb Notebook · True.csv True news · Fake - Fake.csv Fake news
Components 12
Data
Offline CSV sources used for binary news classification.
Pipeline
Notebook-driven text processing and feature engineering flow.
- Notebook · Main executable notebook that runs the end-to-end experiment.
fake-news-detection.ipynb - Load data · Reads both CSVs and assembles the classification corpus.
- Clean text · Lowercases and removes punctuation, URLs, special characters, numbers, and extra spaces.
- TF-IDF · Builds n-gram TF-IDF vectors for the cleaned text corpus.
- Compare models · Ranks classifier performance and selects the strongest model.
- Accuracy output · Notebook-level comparison of classification accuracy.
Models
Scikit-learn classifiers compared on the same feature space.
- Logistic Reg. · Linear baseline model trained on TF-IDF features.
- Decision Tree · Tree-based classifier trained on TF-IDF features.
- Random Forest · Ensemble tree classifier trained on TF-IDF features.
- Gradient Boosting · Boosted classifier trained on TF-IDF features.
Connections 15
- True news → Load data: real articles · Provides the real-news class.
- Fake news → Load data: fake articles · Provides the fake-news class.
- Notebook → Load data: orchestrates · Notebook executes the data-loading step.
- Load data → Clean text: raw text · Merged corpus enters the cleaning boundary.
- Clean text → TF-IDF: normalized text · Cleaned articles are vectorized into sparse features.
- TF-IDF → Logistic Reg.: features · Shared TF-IDF feature matrix.
- TF-IDF → Decision Tree: features · Shared TF-IDF feature matrix.
- TF-IDF → Random Forest: features · Shared TF-IDF feature matrix.
- TF-IDF → Gradient Boosting: features · Shared TF-IDF feature matrix.
- Logistic Reg. → Compare models: score · Model performance feeds comparison.
- Decision Tree → Compare models: score · Model performance feeds comparison.
- Random Forest → Compare models: score · Model performance feeds comparison.
- Gradient Boosting → Compare models: score · Model performance feeds comparison.
- Compare models → Accuracy output: report · Comparison produces accuracy-focused results.
- Notebook → Accuracy output: runs · Notebook displays the final comparison output.