Spaces:
Sleeping
Sleeping
title: News Classification | |
emoji: 📰 | |
colorFrom: green | |
colorTo: indigo | |
sdk: docker | |
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 | |
# News Source Classifier | |
This 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 | |
## Usage | |
You can use this model through our REST API: | |
```python | |
import requests | |
def 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 usage | |
headline = "Scientists discover breakthrough in renewable energy research" | |
result = predict_news_source(headline) | |
print(result) | |
``` | |
Example response: | |
```json | |
{ | |
"label": "nbc", | |
"score": 0.789 | |
} | |
``` | |
## Limitations and Bias | |
This 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 Details | |
The 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 | |
## License | |
This project is licensed under the MIT License. |