This project is a machine learning model that classifies news articles as fake or real. It includes data loading, preprocessing, model training, evaluation, and an API for making predictions.
The Fake News Classifier project aims to build a model that can accurately classify news articles as fake or real based on their title and text content. The project includes data preprocessing, feature engineering, model training, evaluation, and a REST API for serving predictions. The base model was trained on the WELFake dataset published in IEEE Transactions on Computational Social Systems (Volume: 8, Issue: 4, August 2021).
- Data Loading and Preprocessing: Load and clean the dataset to prepare it for model training.
- Feature Engineering: Extract meaningful features from the text data using techniques like TF-IDF.
- Model Training: Train a machine learning model to classify news articles as fake or real.
- Model Evaluation: Evaluate the model's performance using metrics such as precision, recall, and F1-score.
- API for Predictions: Serve the model using a REST API to classify new news articles.
- Python 3.7 or higher
- pip (Python package installer)
- git (for cloning the repository)
- Clone repository
git clone https://github.com/IAMSebyi/Fake-News-Classifier.git
cd Fake-News-Classifier
- Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
- Install dependencies
pip install -r requirements.txt
To preprocess data, train the model, and evaluate it:
python main.py
If you want to specifically train the model:
python -m src.models.train
To start the API server for making predictions:
python -m src.app.api
Once the server is running, you can make POST requests to http://127.0.0.1:5000/predict with a JSON payload containing the text to classify.
Example request:
{
"text": "Sample news article text to classify."
}
Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.
- Fork the repository
- Create a new branch (git checkout -b feature-branch)
- Commit your changes (git commit -m 'Add some feature')
- Push to the branch (git push origin feature-branch)
- Open a pull request
This project is licensed under the MIT License - see the LICENSE file for details.