NewsVerifier is an intelligent web application built using Streamlit that detects whether a news article is REAL or FAKE. It also provides a summarization feature for real news and supports both manual input and URL-based verification.
- 🧠 ML-powered Fake News Detection (Logistic Regression)
- 🌐 Verify via URL or Manual Text Input
- 🔍 Text Summarizer using NLTK for REAL news
- 📁 Logs all predictions with timestamps and source
- 📊 Displays performance metrics for predictions and summaries
- ✅ Clean and interactive UI with error handling
- 🤖 Optional: Gemini LLM verification with reasoning & confidence
NewsVerifier/
├── app.py
├── model/
│ ├── fake_news_model.pkl
│ └── vectorizer.pkl
├── utils/
│ └── news_utils.py
├── fake_news_dataset.csv
├── train_model.py
├── requirement.txt
└── README.md
- Clone this repository
- Create a virtual environment:
python -m venv venv - Activate it:
venv\Scripts\activate(Windows)source venv/bin/activate(Linux/macOS)
- Install dependencies:
pip install -r requirements.txt
Run prepare_data.py
This will merge True.csv and False.csv and keep the dataset ready for prediction.
The model is trained on a labeled fake news dataset with "real" and "fake" labels. During training, 'real' is mapped to 1 and 'fake' to 0.
Summarization is only available for news predicted as REAL. It uses NLTK's sentence tokenizer to generate a condensed version of the article in ~10 lines.
- Binary classification model (Real = 1, Fake = 0)
- Trained on a labeled fake news dataset
- TF-IDF Vectorization for text representation
- Pickled model and vectorizer for deployment
streamlit
scikit-learn
pandas
numpy
nltk
newspaper3k
lxml
sumy
google-generativeai
python-dotenv
The app supports optional news verification via Google Gemini:
- Enable LLM in the app UI
- Provide GEMINI_API_KEY via .env (local) or Streamlit Cloud Secrets
- Get an API key here: https://aistudio.google.com/app/apikey
On Streamlit Cloud, use Manage app → Settings → Secrets and add:
GEMINI_API_KEY = your-actual-api-keyThen redeploy or restart the app.
This project is developed solely for educational and research purposes. It is not intended for production use or to serve as a definitive fact-checking tool. The predictions made by the model may not always be accurate, and users are encouraged to verify news from official and reliable sources only.


