Skip to content

RishDevs/fake-news-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Fake News Detection using Python and Machine Learning

πŸ“Œ Project Overview

This project focuses on building a Fake News Detection system using Python and Machine Learning techniques. The model classifies news articles as "Real" or "Fake" based on their content. The project utilizes Natural Language Processing (NLP) for text preprocessing and various classification algorithms for model building.


πŸ“‚ Project Structure

Fake-News-Detection/ β”‚ β”œβ”€β”€ data/ # Dataset folder β”‚ └── True.csv # Real news dataset β”‚ └── Fake.csv # Fake news dataset β”‚ β”œβ”€β”€ notebooks/ # Jupyter Notebooks for development β”‚ └── fake_news_detection.ipynb β”‚ β”œβ”€β”€ models/ # Saved models β”‚ └── fake_news_model.pkl β”‚ β”œβ”€β”€ app.py # Flask/Streamlit app for deployment β”‚ └── README.md # Project documentation


βš™ Environment Setup

  1. Clone the repository: bash git clone https://github.com/yourusername/Fake-News-Detection.git cd Fake-News-Detection

  2. Create a virtual environment and activate it: bash python -m venv fake-news-env

    For Windows

    fake-news-env\Scripts\activate

    For Mac/Linux

    source fake-news-env/bin/activate

  3. Install the required dependencies: bash pip install -r requirements.txt

  4. Run the Jupyter Notebook: bash jupyter notebook


πŸ“Š Dataset

The dataset used in this project is taken from Kaggle. It contains two files:

  • True.csv: Contains real news articles.
  • Fake.csv: Contains fake news articles.

You can download the dataset from the following link: https://www.kaggle.com/datasets/clmentbisaillon/fake-and-real-news-dataset


πŸ”„ Data Preprocessing

The following preprocessing steps were performed on the dataset:

  • Converting text to lowercase.
  • Removing punctuation and special characters.
  • Removing stopwords.
  • Tokenization.
  • Stemming/Lemmatization.

πŸ€– Machine Learning Model

The following algorithms were used for building the Fake News Detection model:

  1. Logistic Regression
  2. Naive Bayes

The text data was vectorized using TF-IDF (Term Frequency-Inverse Document Frequency) to convert text into numerical features.


πŸ“ˆ Model Evaluation

The model performance was evaluated using:

  • Accuracy Score
  • Confusion Matrix
  • Precision, Recall, F1 Score

πŸš€ How to Run the Project

  1. Run the Jupyter Notebook to train the model: bash jupyter notebook notebooks/fake_news_detection.ipynb

  2. Run the Flask app for deployment: bash python app.py


πŸ›  Technologies Used

  • Python
  • Pandas
  • NumPy
  • Scikit-learn
  • NLTK
  • Matplotlib
  • Seaborn
  • Flask/Streamlit

πŸ“š Further Improvements

  • Try different machine learning algorithms such as Random Forest or SVM.
  • Perform hyperparameter tuning to improve model performance.
  • Deploy the project using Streamlit or Heroku for a user-friendly interface.

πŸ“œ License

This project is licensed under the Apache 2.0 License. Feel free to use and modify the code.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published