B0b3rt1 commited on
Commit
393ffde
·
verified ·
1 Parent(s): e00043c

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +108 -0
README.md ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - pytorch
5
+ - text-classification
6
+ - emotion-detection
7
+ - mlp
8
+ - nlp
9
+ datasets:
10
+ - nelgiriyewithana/emotions
11
+ metrics:
12
+ - accuracy
13
+ - f1
14
+ ---
15
+
16
+ # Emotions Classifier - Deep MLP
17
+
18
+ Model klasyfikacji emocji w tekście oparty na wielowarstwowym perceptronie (MLP) z regularyzacją.
19
+
20
+ ## Model Details
21
+
22
+ - **Architektura:** Deep MLP (5 warstw ukrytych)
23
+ - **Input:** TF-IDF vectors (5000 features)
24
+ - **Output:** 6 klas emocji (sadness, joy, love, anger, fear, surprise)
25
+ - **Accuracy:** 88.69% na zbiorze testowym
26
+ - **Overfitting Gap:** 6.02%
27
+
28
+ ### Architektura:
29
+ ```
30
+ Input (5000)
31
+ → Linear(1024) + BatchNorm + ReLU + Dropout(0.5)
32
+ → Linear(512) + BatchNorm + ReLU + Dropout(0.4)
33
+ → Linear(256) + BatchNorm + ReLU + Dropout(0.3)
34
+ → Linear(128) + BatchNorm + ReLU + Dropout(0.2)
35
+ → Linear(6)
36
+ ```
37
+
38
+ ### Techniki regularyzacji:
39
+ - **Progresywny Dropout:** 0.5 → 0.4 → 0.3 → 0.2
40
+ - **Batch Normalization** po każdej warstwie
41
+ - **L2 Regularization** (weight decay = 1e-4)
42
+
43
+ ## Usage
44
+
45
+ ```python
46
+ import torch
47
+ import pickle
48
+ from sklearn.feature_extraction.text import TfidfVectorizer
49
+
50
+ # Wczytaj model
51
+ model = DeepMLP()
52
+ model.load_state_dict(torch.load("model.pth", map_location="cpu"))
53
+ model.eval()
54
+
55
+ # Wczytaj vectorizer i emotion_map
56
+ with open("vectorizer.pkl", "rb") as f:
57
+ vectorizer = pickle.load(f)
58
+ with open("emotion_map.pkl", "rb") as f:
59
+ emotion_map = pickle.load(f)
60
+
61
+ # Klasyfikacja
62
+ text = "I am so happy today!"
63
+ X = vectorizer.transform([text]).toarray()
64
+ X_tensor = torch.FloatTensor(X)
65
+
66
+ with torch.no_grad():
67
+ outputs = model(X_tensor)
68
+ _, predicted = torch.max(outputs, 1)
69
+ emotion = emotion_map[predicted.item()]
70
+
71
+ print(f"Emotion: {emotion}")
72
+ ```
73
+
74
+ ## Training Details
75
+
76
+ - **Dataset:** Emotions Dataset (Kaggle) - 150,000 examples
77
+ - **Train/Val/Test split:** 70% / 15% / 15%
78
+ - **Optimizer:** Adam (lr=0.001, weight_decay=1e-4)
79
+ - **Batch size:** 256
80
+ - **Epochs:** 10
81
+ - **Loss function:** CrossEntropyLoss
82
+
83
+ ## Performance
84
+
85
+ | Emotion | Precision | Recall | F1-Score |
86
+ |---------|-----------|--------|----------|
87
+ | sadness | 0.95 | 0.90 | 0.92 |
88
+ | joy | 0.89 | 0.93 | 0.91 |
89
+ | love | 0.81 | 0.73 | 0.77 |
90
+ | anger | 0.88 | 0.91 | 0.89 |
91
+ | fear | 0.83 | 0.86 | 0.84 |
92
+ | surprise | 0.72 | 0.77 | 0.74 |
93
+ | **Macro avg** | **0.85** | **0.85** | **0.85** |
94
+
95
+ ## Citation
96
+
97
+ ```bibtex
98
+ @misc{emotions-classifier-mlp,
99
+ author = {Hubert Brzozowski},
100
+ title = {Emotions Classifier - Deep MLP},
101
+ year = {2026},
102
+ publisher = {Hugging Face}
103
+ }
104
+ ```
105
+
106
+ ## License
107
+
108
+ MIT License