Fake News Detection System Using Machine Learning

Fake News Detection System Using Machine Learning

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 NameFake News Detection System
LanguagePython 3.8+
TechnologyMachine Learning, NLP, Deep Learning
Models UsedLogistic Regression, Linear SVM, DistilBERT
Text FeaturesTF-IDF Vectorization
FrontendStreamlit
DatasetLabelled Real and Fake News Articles
DifficultyIntermediate to Advanced
Best ForBCA, 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

LayerTechnologyPurpose
LanguagePython 3.8+Machine learning pipeline and model training
NLPTF-IDF VectorizerConverts text into numerical features
Model 1Logistic RegressionBinary news classification
Model 2Linear SVMClassification of high-dimensional text data
Model 3DistilBERTContext-based transformer classification
Deep LearningPyTorchRuns the DistilBERT model
Web InterfaceStreamlitProvides the browser-based application
Data Processingpandas + numpyDataset 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

  1. Open the Streamlit web application.
  2. Enter or paste a news article into the input area.
  3. Select the required model.
  4. The text is preprocessed before prediction.
  5. TF-IDF is used for Logistic Regression and SVM, while DistilBERT uses its tokenizer.
  6. The selected model generates a REAL or FAKE prediction with a confidence score.

Batch CSV Prediction

  1. Upload a CSV file containing news article text.
  2. The system reads and preprocesses the uploaded articles.
  3. The selected model processes each article.
  4. Predictions and confidence scores are displayed in a table.
  5. The results can be downloaded as a CSV file.

Model Training Process

  1. The labelled real and fake news dataset is loaded using pandas.
  2. The text is cleaned and prepared for training.
  3. TF-IDF features are generated for the traditional machine learning models.
  4. Logistic Regression and Linear SVM are trained using scikit-learn.
  5. DistilBERT is fine-tuned using HuggingFace Transformers and PyTorch.
  6. Trained models and the TF-IDF vectorizer are saved for later prediction.

Download complete source code

Screenshot:

Fake News Detection System Using Machine Learning
Fake News Detection System Using Machine Learning
Fake News Detection System Using Machine Learning
Fake News Detection System Using Machine Learning
Fake News Detection System Using Machine Learning

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

Leave a Reply

Your email address will not be published. Required fields are marked *