Skip to content

muhammadnavas/Fake_News_Predictor

Repository files navigation

Fake News Predictor

A multi-source fake news detection system using ML models and AI-powered analysis. Combines news API verification and advanced analytics in a Streamlit web app.

Features

  • Multi-API News Verification: Checks news existence across NewsAPI, GNews, CurrentsAPI, ContextualWeb, and Google Fact Check.
  • ML Model Analysis: Uses multiple trained models (Naive Bayes, Logistic Regression, Random Forest, CatBoost) for prediction.
  • AI Assessment: Integrates Gemini AI for deep analysis.
  • Content Validation: Ensures only news-like content is analyzed.

Setup

  1. Clone the repository
    git clone https://github.com/muhammadnavas/Fake_News_Predictor.git
    cd Fake_News_Predictor
  2. Install dependencies
    pip install -r requirements.txt
  3. Configure API keys
    • Copy .streamlit/secrets.toml.example to .streamlit/secrets.toml and fill in your keys:
      NEWSAPI_KEY = "your_newsapi_key"
      GNEWS_KEY = "your_gnews_key"
      CURRENTS_KEY = "your_currents_key"
      CONTEXTUALWEB_KEY = "your_contextualweb_key"
      GOOGLE_FACTCHECK_API_KEY = "your_google_factcheck_key"
      GEMINI_API_KEY = "your_gemini_key"
    • Or set keys in .env (see .env.example).
  4. Run the app
    streamlit run app.py

Usage

  • Enter a news headline or article in the input box.
  • The app validates content and runs analysis using selected methods (API, ML, AI).
  • View results in tabs: Verification, ML Models, AI Assessment, Summary.

Troubleshooting

  • No news fetched: Ensure API keys are set and match expected names in both secrets and code.
  • Analysis blocked: Input must be news-like (headline or article, not personal/casual text).
  • Module import errors: Run pip install -r requirements.txt to install all dependencies.
  • Secrets parse error: All values in .streamlit/secrets.toml must be quoted strings.

Security

  • Never commit real API keys to version control. .gitignore excludes .env and .streamlit/secrets.toml by default.
  • Rotate keys if accidentally exposed.

Project Structure

  • app.py — Main Streamlit app
  • ml_analysis.py — ML model loading and analysis
  • content_detector.py — Content validation
  • fetch_news.py — News API integration
  • models/ — Pretrained ML models

About

A multi-source fake news detection system using ML models and AI-powered analysis. Combines news API verification and advanced analytics in a Streamlit web app.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages