Downloads · 30 days
18
26% of all-time downloads
Rakshi1/fake-news-detector
fake-news-detector is a text classification model from Rakshi1. Use it when you need a label for a piece of text. It is set up for keras. The card lists the license as mit.
[](https://colab.research.google.com/github/Rakshi1) [](https://huggingface.co/spaces/Rakshi1/fake-news-detector-app) [](https://huggingface.co/Rakshi1/fake-news-detector)
Downloads · 30 days
18
26% of all-time downloads
All-time downloads
68
Public
Repo size
33.7 MB
Likes
0
Public
Click a slice to open those files.
.keras31.3 MB · 93%
From the Hugging Face model README
🚀 Live Interactive Web App: https://huggingface.co/spaces/Rakshi1/fake-news-detector-app
NLP • Supervised Learning • Binary Text Classification • Long Short-Term Memory
This repository hosts a production-grade Deep Learning text classification model that reads news headlines and body text to classify whether an article is Fake News (0) or Real News (1).
Evaluated on a 20% stratified test split from the ISOT Fake and Real News Dataset:
| Metric | Score | Description |
|---|---|---|
| Accuracy | 91.83% | Overall percentage of correct classifications across test set |
| Precision | 94.04% | Of all articles predicted as Real, 94.04% were actually Real |
| Recall | 89.33% | Of all actual Real articles, 89.33% were successfully detected |
| F1-Score | 91.62% | Balance between precision and recall |
Input News Headline & Article Body
│
▼
Text Preprocessing (Lowercasing, symbol removal, whitespace normalization)
│
▼
Tokenizer (Vocab size: 20,000, Sequence length: 300)
│
▼
Embedding Layer (dim=128, mask_zero=True)
│
▼
LSTM Layer (units=64, return_sequences=False)
│
▼
Dropout Layer (rate=0.3)
│
▼
Dense Layer (units=1, activation='sigmoid')
│
▼
Output: Fake News (0) [< 0.5] or Real News (1) [>= 0.5]
You can load and test this model directly in Python or Google Colab with 4 lines of code:
import pickle
from huggingface_hub import hf_hub_download
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.sequence import pad_sequences
# 1. Download model weights and tokenizer from Hugging Face
model_file = hf_hub_download(repo_id="Rakshi1/fake-news-detector", filename="models/fake_news_lstm.keras")
tok_file = hf_hub_download(repo_id="Rakshi1/fake-news-detector", filename="models/tokenizer.pickle")
# 2. Load artifacts
model = load_model(model_file)
with open(tok_file, 'rb') as f:
tokenizer = pickle.load(f)['tokenizer']
# 3. Test on any news text
def predict(title, text):
content = f"{title} {text}".lower().strip()
seq = tokenizer.texts_to_sequences([content])
padded = pad_sequences(seq, maxlen=300, padding='post', truncating='post')
prob = float(model.predict(padded)[0][0])
label = "Real News" if prob >= 0.5 else "Fake News"
conf = (prob if prob >= 0.5 else 1.0 - prob) * 100
return label, round(conf, 2)
# Quick Test Example
label, confidence = predict(
title="White House signs executive order on cybersecurity",
text="WASHINGTON (Reuters) - Government announces new infrastructure regulations."
)
print(f"Prediction: {label} ({confidence}% confidence)")
models/fake_news_lstm.keras: Trained Keras neural network weights.models/tokenizer.pickle: Fitted tokenizer dictionary.notebooks/fake_news_detection.ipynb: Complete 12-step notebook for Google Colab and Jupyter.src/: Complete source code (model.py, preprocessor.py, train.py, evaluate.py, predict.py).app/app.py: Interactive Streamlit web interface.reports/: Confusion matrix heatmap and training curves.requirements.txt: Environment dependencies.