Views
No views yet
Input (5000)
→ Linear(1024) + BatchNorm + ReLU + Dropout(0.5)
→ Linear(512) + BatchNorm + ReLU + Dropout(0.4)
→ Linear(256) + BatchNorm + ReLU + Dropout(0.3)
→ Linear(128) + BatchNorm + ReLU + Dropout(0.2)
→ Linear(6)1import torch
2import pickle
3from sklearn.feature_extraction.text import TfidfVectorizer
4
5# Wczytaj model
6model = DeepMLP()
7model.load_state_dict(torch.load("model.pth", map_location="cpu"))
8model.eval()
9
10# Wczytaj vectorizer i emotion_map
11with open("vectorizer.pkl", "rb") as f:
12 vectorizer = pickle.load(f)
13with open("emotion_map.pkl", "rb") as f:
14 emotion_map = pickle.load(f)
15
16# Klasyfikacja
17text = "I am so happy today!"
18X = vectorizer.transform([text]).toarray()
19X_tensor = torch.FloatTensor(X)
20
21with torch.no_grad():
22 outputs = model(X_tensor)
23 _, predicted = torch.max(outputs, 1)
24 emotion = emotion_map[predicted.item()]
25
26print(f"Emotion: {emotion}")| Emotion | Precision | Recall | F1-Score |
|---|---|---|---|
| sadness | 0.95 | 0.90 | 0.92 |
| joy | 0.89 | 0.93 | 0.91 |
| love | 0.81 | 0.73 | 0.77 |
| anger | 0.88 | 0.91 | 0.89 |
| fear | 0.83 | 0.86 | 0.84 |
| surprise | 0.72 | 0.77 | 0.74 |
| Macro avg | 0.85 | 0.85 | 0.85 |
1@misc{emotions-classifier-mlp,
2 author = {Hubert Brzozowski},
3 title = {Emotions Classifier - Deep MLP},
4 year = {2026},
5 publisher = {Hugging Face}
6}