Fake News Detection System Using Machine Learning
Fake news has become a major challenge in today’s digital world. Social media platforms, blogs, websites, and messaging applications make it possible to share information within seconds, but not every piece of information available online is reliable. A Fake News Detection System using Machine Learning and NLP provides a practical way to analyze news content and classify it as real or fake.
This project combines Python, Natural Language Processing, Machine Learning, Deep Learning, TF-IDF, SVM, Logistic Regression, DistilBERT, and Streamlit into a complete news classification system. It is suitable for students who want to understand how machine learning models can be trained and deployed through a working web application.
Complete Advance AI Topics: Click Here
Real Time Projects on YouTube:- DecodeIT
Project Overview
| Project Name | Fake News Detection System |
|---|---|
| Language | Python 3.8+ |
| Technology | Machine Learning, NLP, Deep Learning |
| Models Used | Logistic Regression, Linear SVM, DistilBERT |
| Text Features | TF-IDF Vectorization |
| Frontend | Streamlit |
| Dataset | Labelled Real and Fake News Articles |
| Difficulty | Intermediate to Advanced |
| Best For | BCA, MCA, B.Tech CS/IT Students |
Key Features
- Multiple Machine Learning Models: Uses Logistic Regression, Linear SVM, and DistilBERT for fake news classification.
- Single Article Prediction: Users can enter news article text and receive a REAL or FAKE prediction with a confidence score.
- Batch CSV Upload: Allows multiple news articles to be uploaded through a CSV file for bulk prediction.
- Model Comparison: Predictions from different models can be compared for the same news article.
- Download Results: Bulk prediction results can be exported as a CSV file.
- Streamlit Interface: Provides a simple browser-based interface for interacting with the trained models.
- Labelled Dataset: Uses labelled real and fake news articles for model training and classification.
Technologies Used
| Layer | Technology | Purpose |
|---|---|---|
| Language | Python 3.8+ | Machine learning pipeline and model training |
| NLP | TF-IDF Vectorizer | Converts text into numerical features |
| Model 1 | Logistic Regression | Binary news classification |
| Model 2 | Linear SVM | Classification of high-dimensional text data |
| Model 3 | DistilBERT | Context-based transformer classification |
| Deep Learning | PyTorch | Runs the DistilBERT model |
| Web Interface | Streamlit | Provides the browser-based application |
| Data Processing | pandas + numpy | Dataset processing and manipulation |
How the Models Work
TF-IDF + Logistic Regression
The news text is converted into numerical features using TF-IDF Vectorization. These features are then provided to a Logistic Regression model, which classifies the article as REAL or FAKE. It provides a lightweight approach for text classification and is easy to understand for students learning NLP.
TF-IDF + Linear SVM
The same TF-IDF features can be processed by a Linear Support Vector Machine. The SVM separates the real and fake news classes within a high-dimensional feature space, making it suitable for text-based classification tasks.
DistilBERT
DistilBERT is a lightweight transformer model based on BERT. Unlike traditional TF-IDF-based approaches, it can work with the context and structure of the input text. The project uses DistilBERT with PyTorch and HuggingFace Transformers for deep learning-based classification.
How the System Works
Single Article Prediction
- Open the Streamlit web application.
- Enter or paste a news article into the input area.
- Select the required model.
- The text is preprocessed before prediction.
- TF-IDF is used for Logistic Regression and SVM, while DistilBERT uses its tokenizer.
- The selected model generates a REAL or FAKE prediction with a confidence score.
Batch CSV Prediction
- Upload a CSV file containing news article text.
- The system reads and preprocesses the uploaded articles.
- The selected model processes each article.
- Predictions and confidence scores are displayed in a table.
- The results can be downloaded as a CSV file.
Model Training Process
- The labelled real and fake news dataset is loaded using pandas.
- The text is cleaned and prepared for training.
- TF-IDF features are generated for the traditional machine learning models.
- Logistic Regression and Linear SVM are trained using scikit-learn.
- DistilBERT is fine-tuned using HuggingFace Transformers and PyTorch.
- Trained models and the TF-IDF vectorizer are saved for later prediction.
Download complete source code
Screenshot:






How to Run This Project
Step 1: Enter the Project Folder
cd fake-news-detection
Step 2: Create a Virtual Environment
Windows:
python -m venv venv
venv\Scripts\activate
macOS / Linux:
python -m venv venv
source venv/bin/activate
Step 3: Install Dependencies
pip install -r requirements.txt
The project requires packages such as:
pandas
numpy
scikit-learn
transformers
torch
streamlit
Step 4: Train the Models
python train.py
This trains the available models and saves the trained files for use by the application.
Step 5: Start the Streamlit Application
streamlit run app.py
After running the command, open the provided local URL in your browser and use the application to analyze news articles.
Future Scope and Improvements
- Multi-Language Detection: Extend the system to support languages such as Hindi and Spanish.
- Image and Video Analysis: Analyze media content associated with news.
- Source Credibility Analysis: Add additional analysis for identifying potentially unreliable sources.
- Browser Extension: Develop a browser-based solution for checking news while browsing.
- AI-Generated Content Detection: Extend the system to identify content generated by AI tools.
- Further Research: The comparison of multiple models can provide a foundation for further academic research.
Keywords
Fake News Detection System India, Fake News Detection System Kaggle, Fake News Detection System Dataset, Fake News Detection System App, Fake News Detection System GeeksforGeeks, Fake News Detection Dataset Kaggle, Fake News Detection Dataset India, Fake News Detection Project PPT, Fake News Detection System Project, Fake News Detection System Project PDF, Fake News Detection System GitHub, Fake News Detection System Python, Fake News Detection System PDF, Fake News Detection Using Machine Learning, Fake News Detection Website, Fake News Detection System in Machine Learning,Fake News Detection System Using Machine Learning,Fake News Detection System Using Machine Learning