Spaces:
Sleeping
Sleeping
Jiahuita commited on
Commit ·
4931f6a
1
Parent(s): 8f3a7a6
updated readme
Browse filesFiles changed (2)
- README copy.mdDeleted-97
- README.md+78-2
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697---
title: News Source Classifier
emoji: 📰
colorFrom: blue
colorTo: red
sdk: fastapi
sdk_version: 0.95.2
app_file: app.py
pinned: false
language: en
license: mit
tags:
- text-classification
- news-classification
- LSTM
- tensorflow
pipeline_tag: text-classification
widget:
- example_title: "Crime News Headline"
text: "Wife of murdered Minnesota pastor hired 3 men to kill husband after affair: police"
- example_title: "Science News Headline"
text: "Scientists discover breakthrough in renewable energy research"
- example_title: "Political News Headline"
text: "Presidential candidates face off in heated debate over climate policies"
model-index:
- name: News Source Classifier
results:
- task:
type: text-classification
name: Text Classification
dataset:
name: Custom Dataset
type: Custom
metrics:
- name: Accuracy
type: accuracy
value: 0.82
---
# News Source Classifier
This model classifies news headlines as either Fox News or NBC News using an LSTM neural network.
## Model Description
- **Model Architecture**: LSTM Neural Network
- **Input**: News headlines (text)
- **Output**: Binary classification (Fox News vs NBC)
- **Training Data**: Large collection of headlines from both news sources
- **Performance**: Achieves approximately 82% accuracy on the test set
## Usage
You can use this model directly with a FastAPI endpoint:
```python
import requests
response = requests.post(
"https://huggingface.co/Jiahuita/NewsSourceClassification",
json={"text": "Your news headline here"}
)
print(response.json())
```
Or use it locally:
```python
from transformers import pipeline
classifier = pipeline("text-classification", model="Jiahuita/NewsSourceClassification")
result = classifier("Your news headline here")
print(result)
```
Example response:
```json
{
"label": "foxnews",
"score": 0.875
}
```
## Limitations and Bias
This model has been trained on news headlines from specific sources and time periods, which may introduce certain biases. Users should be aware of these limitations when using the model.
## Training
The model was trained using:
- TensorFlow 2.13.0
- LSTM architecture
- Binary cross-entropy loss
- Adam optimizer
## License
This project is licensed under the MIT License.12345678910---title: News Classificationemoji: 😻colorFrom: greencolorTo: indigosdk: dockerpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586---title: News Classificationemoji: 📰colorFrom: greencolorTo: indigosdk: dockersdk_version: 0.95.2app_file: app.pypinned: falselanguage: enlicense: mittags:- text-classification- news-classification- LSTM- tensorflowpipeline_tag: text-classification---# News Source ClassifierThis model classifies news headlines as either Fox News or NBC News using a deep learning LSTM (Long Short-Term Memory) neural network architecture.## Model Description### Architecture- Input Layer: Embedding layer (vocab_size=74,934, embedding_dim=128)- LSTM Layer 1: 128 units with return sequences- Dropout Layer 1: For regularization- LSTM Layer 2: 64 units- Dropout Layer 2: For regularization- Output Layer: Dense layer with 2 units (binary classification)### Technical Details- Total Parameters: 9,772,676 (37.28 MB)- Training Parameters: 9,772,674 (37.28 MB)- Input Shape: (41, ) - sequences of length 41- Performance: Achieves binary classification of news sources## UsageYou can use this model through our REST API:```pythonimport requestsdef predict_news_source(text):response = requests.post("https://jiahuita-news-classification.hf.space/predict",json={"text": text},headers={"Content-Type": "application/json"})return response.json()# Example usageheadline = "Scientists discover breakthrough in renewable energy research"result = predict_news_source(headline)print(result)```Example response:```json{"label": "nbc","score": 0.789}```## Limitations and BiasThis model has been trained on news headlines from specific sources and time periods, which may introduce certain biases:- Training data is limited to two news sources- Headlines represent a specific time period- Model may be sensitive to writing style rather than just content## Training DetailsThe model was trained using:- TensorFlow 2.10.0- Binary cross-entropy loss- Embedding layer for text representation- Dual LSTM layers with dropout for robust feature extraction- Dense layer with softmax activation for final classification## LicenseThis project is licensed under the MIT License.
README copy.mdDeleted-97
README.md+78-2