https://github.com/shadowfaxx1/fake-news-detection
Fake News Detection System
https://github.com/shadowfaxx1/fake-news-detection
Last synced: 2 months ago
JSON representation
Fake News Detection System
- Host: GitHub
- URL: https://github.com/shadowfaxx1/fake-news-detection
- Owner: shadowfaxx1
- Created: 2023-07-26T08:18:56.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-26T08:20:44.000Z (almost 2 years ago)
- Last Synced: 2025-01-26T08:41:42.182Z (4 months ago)
- Language: Jupyter Notebook
- Homepage:
- Size: 11.1 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fake News Detection
A machine learning project to detect fake news articles using TF-IDF vectorization and the PassiveAggressiveClassifier algorithm.
## Installation
1. Clone the repository:
```bash
git clone
cd fake-news-detection
```2. Install the required dependencies:
```bash
pip install -r requirements.txt
```## Usage
1. Import the required libraries:
```python
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import PassiveAggressiveClassifier
```2. Initialize a TfidfVectorizer:
```python
tfidf_vectorizer = TfidfVectorizer(stop_words='english', max_df=0.7)
```3. Fit and transform the training set, and transform the test set:
```python
tfidf_train = tfidf_vectorizer.fit_transform(x_train)
tfidf_test = tfidf_vectorizer.transform(x_test)
```4. Initialize a PassiveAggressiveClassifier:
```python
pac = PassiveAggressiveClassifier(max_iter=50)
pac.fit(tfidf_train, y_train)
```5. Predict on the test set and calculate accuracy:
```python
y_pred = pac.predict(tfidf_test)
score = accuracy_score(y_test, y_pred)
print(f'Accuracy: {round(score*100, 2)}%')
```## Data
The project uses a dataset containing labeled news articles, where each article is labeled as either 'FAKE' or 'REAL'.
## Model
The model used is the PassiveAggressiveClassifier combined with TF-IDF vectorization for text classification.
## Evaluation
The model's performance is evaluated using accuracy, precision, recall, F1-score, ROC curve, and AUC score.
## License
MIT License
Please feel free to add more details or modify the content as per your specific project. A concise README.md provides the essential information to users and contributors in a straightforward manner.