This upgraded version of the classic Fake News Detection project adds an LLM-powered explainability layer.
Traditional ML models classify news articles, while GPT-4o-mini provides a human-readable justification of why an article is likely fake or real.
| Layer | Technology | Purpose |
|---|---|---|
| 🧩 Machine Learning | Scikit-Learn | Core fake/real classification |
| 🧠 Generative AI | OpenAI GPT-4o-mini | Natural-language explanations |
| 💻 Frontend | HTML + CSS | Simple, responsive web interface |
| 🌐 Backend | Flask | Web app for serving predictions |
| 💾 Storage | joblib, pandas | Model + dataset handling |
- 📰 Classifies news as FAKE or REAL using Passive Aggressive Classifier.
- 🔍 Generates explanations via GPT-4o-mini for every prediction.
- 🌐 Flask-based web app with an easy-to-use text input box.
- 📈 Confusion matrix & accuracy summary available on
/metrics. - 🧱 Modular folder structure for quick extension or retraining.
Fake_News_Detection/
│
├── app.py # Flask entry point
├── requirements.txt # Dependencies
├── model/
│ ├── fake_news_model.pkl # Trained PAC model
│ └── tfidf_vectorizer.pkl # TF-IDF vectorizer
│
├── data/
│ └── news.csv # Dataset (Kaggle-style)
│
├── utils/
│ ├── gpt_explainer.py # GPT-4o-mini text explanations
│ ├── model_loader.py # Load + predict helpers
│ └── preprocess.py # Text preprocessing utils
│
├── templates/
│ └── index.html # Web interface
│
├── static/
│ └── style.css # Styling
│
└── README.md
# 1️⃣ Clone the repository
git clone https://github.com/ramarav/Fake_News_Detection.git
cd Fake_News_Detection
# 2️⃣ Create a virtual environment
python -m venv venv
source venv/bin/activate # on Windows use venv\Scripts\activate
# 3️⃣ Install dependencies
pip install -r requirements.txt
# 4️⃣ Add your OpenAI API key (for explanations)
set OPENAI_API_KEY=your_api_key_here # Windows
export OPENAI_API_KEY=your_api_key_here # macOS/Linux
# 5️⃣ Run Flask app
python app.pyThen open http://localhost:5000 🎯
| Input | Prediction | Explanation |
|---|---|---|
| “NASA confirms aliens discovered near Mars base.” | FAKE | “This resembles tabloid-style unverifiable claims.” |
| “UN reports global hunger dropped by 10% in 2024.” | REAL | “The phrasing and reference to official data suggest credibility.” |
| Metric | Value |
|---|---|
| Accuracy | 93.13% |
| Classifier | PassiveAggressiveClassifier |
| Vectorizer | TF-IDF (max_df=0.7, stop_words='english') |
POST /predict
curl -X POST http://127.0.0.1:5000/predict -H "Content-Type: application/json" -d '{"text": "Breaking: New vaccine approved by WHO"}'Response:
{
"prediction": "REAL",
"explanation": "WHO approvals are verified through credible institutional sources."
}- Integrate news source credibility scoring
- Add multilingual detection
- Deploy using Docker + Render
- Support voice-based input (Speech-to-Text)
Mekala Ramarao
AMD India
Focus: AI/ML applications in NLP, GPU analytics, and intelligent automation.
📧 LinkedIn