Combat misinformation with cutting-edge NLP and Machine Learning
Quick Start • Features • API • Android App • Documentation
- 🎯 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
- 🐳 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
- 📝 LIAR Dataset: 10,000+ labeled statements
- 🧹 Preprocessing pipeline: Tokenization, stemming, stopword removal
- 📈 EDA included: Distribution plots, quality checks
- 🎨 Visualizations: Confusion matrices, precision-recall curves
- 📖 Complete documentation with guides
- 🧪 30+ unit tests for reliability
- 🔧 One-command setup automation
- 💻 Multiple interfaces: CLI, API, Mobile
- 🎯 Type hints and docstrings
The API is already hosted and running:
https://spotliar.onrender.com
Test it instantly:
curl https://spotliar.onrender.com/api/healthDownload and install the APK to start verifying news immediately!
- Works on any network (WiFi/Mobile data)
- No setup required
- Instant predictions
git clone <your-repo-url>
cd Fake_News_Detection-master
chmod +x install.sh && ./install.sh
source .venv/bin/activate
python api_server.pydocker-compose up -d
curl http://localhost:5000/api/healthpython prediction.py
Enter news text: Scientists discover new planet
Result: Real News
Confidence: 87.3%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
- Open
android/in Android Studio - Build and run on device
- Enter news text and get instant verification
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 |
# 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"}'- ✨ Modern Material Design 3 UI
- 🎨 Jetpack Compose interface
- 🔄 Real-time predictions
- 📊 Confidence visualization
- 🌐 WiFi and USB connectivity
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.apkFor local development, update RetrofitClient.kt:
private const val BASE_URL = "http://localhost:5000/" // or your local IPSee Android Setup Guide and Wireless Setup for details.
Raw Text → Tokenization → Stopword Removal → Stemming → Clean Text
Clean Text → TF-IDF Vectorization → N-grams (1-5) → Feature Matrix
Feature Matrix → Multiple ML Models → Grid Search → Best Model Selection
New Text → Preprocessing → Feature Extraction → Model → Prediction + Confidence
- Accuracy: 70.2%
- F1 Score: 0.701
- Precision: 0.68
- Recall: 0.72
| 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 ⚡ |
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
- Python 3.6+: Core language
- scikit-learn: ML algorithms
- NLTK: Natural language processing
- Flask: REST API framework
- pandas/numpy: Data manipulation
- Kotlin: Android development
- Jetpack Compose: Modern UI toolkit
- Retrofit: HTTP client
- Material Design 3: UI components
- Docker: Containerization
- pytest: Testing framework
- GitHub Actions: CI/CD (optional)
- 📘 Quick Start Guide - Get running in 5 minutes
- 📗 Deployment Guide - Production deployment
- 📙 API Documentation - Complete API reference
- 📕 Android Setup - Mobile app guide
- 📓 Contributing Guide - How to contribute
- 📔 Wireless Setup - WiFi configuration
Currently deployed on Render.com:
- URL: https://spotliar.onrender.com
- Status: ✅ Running
- Uptime: 24/7 (free tier may sleep after inactivity)
./start-everything.shRender.com (Recommended - Free):
- Fork this repository
- Connect to Render.com
- Deploy with one click
- 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.
pytest
pytest --cov=. --cov-report=html
make test-coverageTest Coverage: 30+ unit tests covering:
- ✅ API endpoints
- ✅ Data preprocessing
- ✅ Model predictions
- ✅ Feature extraction
- Source: ACL 2017 Paper by William Yang Wang
- Size: 12,836 labeled statements
- Classes: Binary (True/False)
- Features: Statement text, speaker, context
- Training: 10,240 samples
- Testing: 1,267 samples
- Validation: 1,284 samples
- ✅ 5 ML models implemented
- ✅ REST API with Flask
- ✅ Android app with Jetpack Compose
- ✅ Docker containerization
- ✅ Comprehensive documentation
- 🔮 Deep learning models (BERT, GPT)
- 🌍 Multi-language support
- 🎨 Web interface
- 📊 Real-time dashboard
- 🔐 User authentication
- 📈 Model explainability (LIME, SHAP)
- 🚀 Kubernetes deployment
- 📱 iOS app
We welcome contributions! See CONTRIBUTING.md for guidelines.
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Original Author: nishitpatel01
- Contributors: See contributors
- LIAR Dataset: William Yang Wang, ACL 2017
- scikit-learn: Machine learning library
- NLTK: Natural language toolkit
- Flask: Web framework
- Jetpack Compose: Android UI toolkit
- 📧 Email: [email protected]
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
- 📖 Docs: Full Documentation
If you find this project useful, please consider giving it a star! ⭐
