File size: 2,170 Bytes
aef9aa2
 
4931f6a
aef9aa2
 
 
4931f6a
 
aef9aa2
4931f6a
 
 
 
 
 
 
 
aef9aa2
 
4931f6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
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.