File size: 5,044 Bytes
c259525
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b023498
 
c259525
b023498
c259525
b023498
 
c259525
b023498
 
c259525
 
 
 
 
 
 
 
 
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---
license: mit
language:
- id
- en
metrics:
- accuracy
- recall
- precision
- confusion_matrix
pipeline_tag: text-classification
tags:
- presidential election
- indonesia
- multiclass
---



Berikut adalah README.txt yang menarik dan informatif untuk model yang telah Anda unggah ke Kaggle Model Hub:

---

# Fine-tuned DistilBERT Model for Indonesian Text Classification

## Overview

This repository contains a fine-tuned version of the DistilBERT model (based on [cahya/distilbert-base-indonesian](https://huggingface.co/cahya/distilbert-base-indonesian)) for Indonesian text classification. The model is trained to classify text into eight distinct categories, including politics, socio-cultural, defense and security, ideology, economy, natural resources, demography, and geography.

## Dataset

The dataset used for training the model underwent significant augmentation and balancing to address class imbalance issues. Below are the details of the dataset before and after augmentation:

### Before Augmentation
| Category                | Count |
|-------------------------|-------|
| Politik                 | 2972  |
| Sosial Budaya           | 587   |
| Pertahanan dan Keamanan | 400   |
| Ideologi                | 400   |
| Ekonomi                 | 367   |
| Sumber Daya Alam        | 192   |
| Demografi               | 62    |
| Geografi                | 20    |

### After Augmentation
| Category                | Count |
|-------------------------|-------|
| Politik                 | 2969  |
| Demografi               | 427   |
| Sosial Budaya           | 422   |
| Ideologi                | 343   |
| Pertahanan dan Keamanan | 331   |
| Ekonomi                 | 309   |
| Sumber Daya Alam        | 156   |
| Geografi                | 133   |

## Label Encoding

| Encoded | Label                     |
|---------|---------------------------|
| 0       | Demografi                 |
| 1       | Ekonomi                   |
| 2       | Geografi                  |
| 3       | Ideologi                  |
| 4       | Pertahanan dan Keamanan   |
| 5       | Politik                   |
| 6       | Sosial Budaya             |
| 7       | Sumber Daya Alam          |

## Data Split

The dataset was split into training and testing sets with an 85:15 ratio.

- **Train Size:** 4326 samples
- **Test Size:** 764 samples

## Model Training

The model was trained for 4 epochs, achieving the following results:

| Epoch | Train Loss | Train Accuracy |
|-------|------------|----------------|
| 1     | 1.0240     | 0.6766         |
| 2     | 0.5615     | 0.8220         |
| 3     | 0.3270     | 0.9014         |
| 4     | 0.1759     | 0.9481         |

### Training Completion
- **Test Loss:** 0.7948
- **Test Accuracy:** 0.7687
- **Test Balanced Accuracy:** 0.7001

## Model Evaluation

The model was evaluated using precision, recall, and F1 scores, with the following results:

- **Precision Score:** 0.7714
- **Recall Score:** 0.7696
- **F1 Score:** 0.7697

### Classification Report

| Category                | Precision | Recall | F1-Score | Support |
|-------------------------|-----------|--------|----------|---------|
| Demografi               | 0.94      | 0.91   | 0.92     | 64      |
| Ekonomi                 | 0.67      | 0.72   | 0.69     | 46      |
| Geografi                | 0.95      | 0.95   | 0.95     | 20      |
| Ideologi                | 0.71      | 0.56   | 0.62     | 52      |
| Pertahanan dan Keamanan | 0.69      | 0.66   | 0.67     | 50      |
| Politik                 | 0.84      | 0.85   | 0.84     | 446     |
| Sosial Budaya           | 0.38      | 0.40   | 0.39     | 63      |
| Sumber Daya Alam        | 0.50      | 0.57   | 0.53     | 23      |

- **Accuracy:** 0.7696
- **Balanced Accuracy:** 0.7001
- **Macro Avg Precision:** 0.71
- **Macro Avg Recall:** 0.70
- **Macro Avg F1-Score:** 0.70
- **Weighted Avg Precision:** 0.77
- **Weighted Avg Recall:** 0.77
- **Weighted Avg F1-Score:** 0.77

## Usage

To use this model, you can load it using the Hugging Face Transformers library:

```python
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-classification", model="Rendika/Trained-DistilBERT-Indonesia-Presidential-Election-Balanced-Dataset")

# Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("Rendika/Trained-DistilBERT-Indonesia-Presidential-Election-Balanced-Dataset")
model = AutoModelForSequenceClassification.from_pretrained("Rendika/Trained-DistilBERT-Indonesia-Presidential-Election-Balanced-Dataset")
```

## Conclusion

This fine-tuned DistilBERT model for Indonesian text classification demonstrates robust performance across various categories. The augmentation and balancing of the dataset have contributed significantly to the model's ability to generalize well on the test set.

Feel free to use this model for your Indonesian text classification tasks, and don't hesitate to reach out if you have any questions or feedback.

---