Skip to content
w0lzardPublic

About

AI-powered fake news detector using ML and NLP. Verify news instantly via REST API or Android app. 70%+ accuracy on 10K+ statements.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

SpotLiar Logo

SpotLiar - Fake News Detection

AI-Powered Truth Verification with Machine Learning

Python Flask Android License Docker

Combat misinformation with cutting-edge NLP and Machine Learning

Quick Start โ€ข Features โ€ข API โ€ข Android App โ€ข Documentation


๐ŸŒŸ Features

๐Ÿค– Machine Learning Models

  • ๐ŸŽฏ 5 Algorithms: Naive Bayes, Logistic Regression, SVM, SGD, Random Forest
  • ๐Ÿ“Š 70%+ Accuracy on LIAR benchmark dataset
  • ๐Ÿ” Advanced NLP: TF-IDF, N-grams (1-5), Bag of Words
  • โšก Real-time predictions with confidence scores
  • ๐Ÿ“ˆ Model comparison with learning curves

๐Ÿš€ Production Ready

  • ๐Ÿณ Docker containerized for instant deployment
  • ๐ŸŒ REST API with Flask backend
  • ๐Ÿ“ฑ Native Android app with Jetpack Compose UI
  • ๐Ÿ”’ Network security and HTTPS ready
  • ๐Ÿ“Š Batch prediction support

๐Ÿ“Š Data & Analysis

  • ๐Ÿ“ LIAR Dataset: 10,000+ labeled statements
  • ๐Ÿงน Preprocessing pipeline: Tokenization, stemming, stopword removal
  • ๐Ÿ“ˆ EDA included: Distribution plots, quality checks
  • ๐ŸŽจ Visualizations: Confusion matrices, precision-recall curves

๐Ÿ› ๏ธ Developer Experience

  • ๐Ÿ“– Complete documentation with guides
  • ๐Ÿงช 30+ unit tests for reliability
  • ๐Ÿ”ง One-command setup automation
  • ๐Ÿ’ป Multiple interfaces: CLI, API, Mobile
  • ๐ŸŽฏ Type hints and docstrings

๐Ÿš€ Quick Start

๐ŸŒ Live Demo (No Installation Required!)

The API is already hosted and running:

https://spotliar.onrender.com

Test it instantly:

curl https://spotliar.onrender.com/api/health

๐Ÿ“ฑ Android App

Download and install the APK to start verifying news immediately!

  • Works on any network (WiFi/Mobile data)
  • No setup required
  • Instant predictions

โšก Local Installation

git clone <your-repo-url>
cd Fake_News_Detection-master

chmod +x install.sh && ./install.sh
source .venv/bin/activate
python api_server.py

๐Ÿณ Docker

docker-compose up -d
curl http://localhost:5000/api/health

๐Ÿ’ป Usage

๐Ÿ–ฅ๏ธ Command Line

python prediction.py

Enter news text: Scientists discover new planet
Result: Real News
Confidence: 87.3%

๐ŸŒ REST API

import requests

# Use the live API
response = requests.post('https://spotliar.onrender.com/api/predict',
    json={'text': 'Breaking news: New discovery announced'})

print(response.json())
{
  "success": true,
  "prediction": "Real News",
  "is_fake": false,
  "confidence": 0.873,
  "confidence_percentage": 87.3
}

Live API Base URL: https://spotliar.onrender.com

๐Ÿ“ฑ Android App

  1. Open android/ in Android Studio
  2. Build and run on device
  3. Enter news text and get instant verification

๐Ÿ”Œ API Endpoints

Base URL: https://spotliar.onrender.com

Endpoint Method Description
/ GET Root endpoint (200 OK)
/api/health GET Health check
/api/predict POST Predict single news article
/api/batch-predict POST Predict multiple articles
/api/info GET API information

Example Request

# Live API
curl -X POST https://spotliar.onrender.com/api/predict \
  -H "Content-Type: application/json" \
  -d '{"text": "Your news article here"}'

# Local development
curl -X POST http://localhost:5000/api/predict \
  -H "Content-Type: application/json" \
  -d '{"text": "Your news article here"}'

๐Ÿ“ฑ Android App

Android App

Features

  • โœจ Modern Material Design 3 UI
  • ๐ŸŽจ Jetpack Compose interface
  • ๐Ÿ”„ Real-time predictions
  • ๐Ÿ“Š Confidence visualization
  • ๐ŸŒ WiFi and USB connectivity

Setup

The app is pre-configured to use the live API at https://spotliar.onrender.com

Build and Install:

cd android
./gradlew assembleDebug
adb install app/build/outputs/apk/debug/app-debug.apk

For local development, update RetrofitClient.kt:

private const val BASE_URL = "http://localhost:5000/"  // or your local IP

See Android Setup Guide and Wireless Setup for details.


๐Ÿง  How It Works

1๏ธโƒฃ Data Preprocessing

Raw Text โ†’ Tokenization โ†’ Stopword Removal โ†’ Stemming โ†’ Clean Text

2๏ธโƒฃ Feature Extraction

Clean Text โ†’ TF-IDF Vectorization โ†’ N-grams (1-5) โ†’ Feature Matrix

3๏ธโƒฃ Model Training

Feature Matrix โ†’ Multiple ML Models โ†’ Grid Search โ†’ Best Model Selection

4๏ธโƒฃ Prediction

New Text โ†’ Preprocessing โ†’ Feature Extraction โ†’ Model โ†’ Prediction + Confidence

๐Ÿ“Š Model Performance

Logistic Regression (Best Model)

  • Accuracy: 70.2%
  • F1 Score: 0.701
  • Precision: 0.68
  • Recall: 0.72
Learning Curve

Model Comparison

Model Accuracy F1 Score Training Time
Logistic Regression 70.2% 0.701 Fast โšก
Random Forest 66.5% 0.666 Slow ๐ŸŒ
Naive Bayes 72.3% 0.723 Fastest โšกโšก
Linear SVM 67.9% 0.679 Medium ๐Ÿšถ
SGD 71.8% 0.719 Fast โšก

๐Ÿ“ Project Structure

Fake_News_Detection-master/
โ”œโ”€โ”€ ๐Ÿ“„ Core ML Modules
โ”‚   โ”œโ”€โ”€ DataPrep.py              # Data preprocessing
โ”‚   โ”œโ”€โ”€ FeatureSelection.py      # Feature extraction
โ”‚   โ”œโ”€โ”€ classifier.py            # Model training
โ”‚   โ”œโ”€โ”€ model_trainer.py         # Training utilities
โ”‚   โ”œโ”€โ”€ prediction.py            # CLI prediction
โ”‚   โ””โ”€โ”€ api_server.py            # REST API
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ฆ Models & Data
โ”‚   โ”œโ”€โ”€ final_model.sav          # Trained model
โ”‚   โ”œโ”€โ”€ train.csv                # Training data
โ”‚   โ”œโ”€โ”€ test.csv                 # Test data
โ”‚   โ””โ”€โ”€ liar_dataset/            # Original dataset
โ”‚
โ”œโ”€โ”€ ๐Ÿณ Deployment
โ”‚   โ”œโ”€โ”€ Dockerfile               # Container definition
โ”‚   โ”œโ”€โ”€ docker-compose.yml       # Orchestration
โ”‚   โ””โ”€โ”€ .env.example             # Configuration
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ฑ Android App
โ”‚   โ””โ”€โ”€ android/                 # Jetpack Compose app
โ”‚
โ”œโ”€โ”€ ๐Ÿงช Testing
โ”‚   โ””โ”€โ”€ tests/                   # 30+ unit tests
โ”‚
โ””โ”€โ”€ ๐Ÿ“š Documentation
    โ”œโ”€โ”€ README.md                # This file
    โ”œโ”€โ”€ QUICKSTART.md            # Quick start guide
    โ”œโ”€โ”€ DEPLOYMENT.md            # Deployment guide
    โ””โ”€โ”€ CONTRIBUTING.md          # Contribution guide

๐Ÿ› ๏ธ Tech Stack

Backend

  • Python 3.6+: Core language
  • scikit-learn: ML algorithms
  • NLTK: Natural language processing
  • Flask: REST API framework
  • pandas/numpy: Data manipulation

Frontend

  • Kotlin: Android development
  • Jetpack Compose: Modern UI toolkit
  • Retrofit: HTTP client
  • Material Design 3: UI components

DevOps

  • Docker: Containerization
  • pytest: Testing framework
  • GitHub Actions: CI/CD (optional)

๐Ÿ“– Documentation


๐Ÿš€ Deployment

โ˜๏ธ Production (Live)

Currently deployed on Render.com:

Local Development

./start-everything.sh

Deploy Your Own

Render.com (Recommended - Free):

  1. Fork this repository
  2. Connect to Render.com
  3. Deploy with one click
  4. See CLOUD_DEPLOYMENT.md for details

Other Platforms:

  • ๐ŸŒŠ Railway: $5 credit/month
  • โšก Fly.io: Free tier available
  • ๐Ÿ”ฅ Heroku: $5/month
  • โ˜๏ธ AWS/GCP: Full control

See CLOUD_DEPLOYMENT.md for complete deployment guides.


๐Ÿงช Testing

pytest
pytest --cov=. --cov-report=html
make test-coverage

Test Coverage: 30+ unit tests covering:

  • โœ… API endpoints
  • โœ… Data preprocessing
  • โœ… Model predictions
  • โœ… Feature extraction

๐Ÿ“Š Dataset

LIAR Dataset

  • Source: ACL 2017 Paper by William Yang Wang
  • Size: 12,836 labeled statements
  • Classes: Binary (True/False)
  • Features: Statement text, speaker, context

Data Distribution

  • Training: 10,240 samples
  • Testing: 1,267 samples
  • Validation: 1,284 samples

๐ŸŽฏ Roadmap

Current Version (v1.0)

  • โœ… 5 ML models implemented
  • โœ… REST API with Flask
  • โœ… Android app with Jetpack Compose
  • โœ… Docker containerization
  • โœ… Comprehensive documentation

Future Enhancements

  • ๐Ÿ”ฎ Deep learning models (BERT, GPT)
  • ๐ŸŒ Multi-language support
  • ๐ŸŽจ Web interface
  • ๐Ÿ“Š Real-time dashboard
  • ๐Ÿ” User authentication
  • ๐Ÿ“ˆ Model explainability (LIME, SHAP)
  • ๐Ÿš€ Kubernetes deployment
  • ๐Ÿ“ฑ iOS app

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Quick Contribution Steps

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open Pull Request

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ‘ฅ Authors


๐Ÿ™ Acknowledgments

  • LIAR Dataset: William Yang Wang, ACL 2017
  • scikit-learn: Machine learning library
  • NLTK: Natural language toolkit
  • Flask: Web framework
  • Jetpack Compose: Android UI toolkit

๐Ÿ“ž Support


โญ Star History

If you find this project useful, please consider giving it a star! โญ


๐ŸŽฏ Made with โค๏ธ for fighting misinformation

โฌ† Back to Top

About

AI-powered fake news detector using ML and NLP. Verify news instantly via REST API or Android app. 70%+ accuracy on 10K+ statements.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages