Views
No views yet
1from transformers import pipeline
2
3classifier = pipeline(
4 "text-classification",
5 model="Akan-Brown/fakenews-detector",
6 truncation=True,
7 max_length=512
8)
9
10result = classifier("Your news article text here")[0]
11label = "REAL" if result["label"] == "LABEL_1" else "FAKE"
12print(f"Prediction: {label} ({result['score']:.2%} confidence)")| Label | Meaning |
|---|---|
LABEL_0 | FAKE news |
LABEL_1 | REAL news |
| Metric | Score |
|---|---|
| Accuracy | reported after evaluation |
| F1 Score (weighted) | reported after evaluation |
| Precision | reported after evaluation |
| Recall | reported after evaluation |
Replace the values above with your actual results from Cell 7 output.
1from transformers import pipeline
2
3classifier = pipeline(
4 "text-classification",
5 model="Akan-Brown/fakenews-detector",
6 truncation=True,
7 max_length=512
8)
9
10articles = [
11 "Federal Reserve raises interest rates by 0.25% amid inflation concerns.",
12 "SHOCKING: Government putting microchips in vaccines, whistleblower reveals!!!",
13]
14
15for article in articles:
16 result = classifier(article)[0]
17 label = "REAL ✅" if result["label"] == "LABEL_1" else "FAKE ❌"
18 print(f"{label} ({result['score']:.2%}) — {article[:60]}")1import os
2from huggingface_hub import InferenceClient
3
4client = InferenceClient(
5 provider="hf-inference",
6 api_key=os.environ["HF_TOKEN"],
7)
8
9result = client.text_classification(
10 "Your news article text here",
11 model="Akan-Brown/fakenews-detector",
12)1@article{verma2021WELFake,
2 title={WELFake: Word Embedding over Linguistic Features for Fake News Detection},
3 author={Verma, Parth and Agrawal, Priya},
4 journal={IEEE Transactions on Computational Social Systems},
5 year={2021}
6}