AnkitAI commited on
Commit
a5e747b
Β·
verified Β·
1 Parent(s): ba3dffb

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +130 -25
README.md CHANGED
@@ -29,30 +29,121 @@ Fast Emotion-X is a state-of-the-art emotion detection model fine-tuned from Mic
29
  - **πŸ“Š Dataset:** [dair-ai/emotion](https://huggingface.co/dair-ai/emotion)
30
  - **βš™οΈ Fine-tuning:** This model was fine-tuned for emotion detection with a classification head for six emotional categories (anger, disgust, fear, joy, sadness, surprise).
31
 
32
- ## πŸ‹οΈ Training
33
 
34
- The model was trained using the following parameters:
 
 
 
 
 
 
 
35
 
36
- - **πŸ”§ Learning Rate:** 2e-5
37
- - **πŸ“¦ Batch Size:** 4
38
- - **βš–οΈ Weight Decay:** 0.01
39
- - **πŸ“… Evaluation Strategy:** Epoch
40
 
41
- ### πŸ‹οΈ Training Details
42
 
43
- - **πŸ“‰ Eval Loss:** 0.0858
44
- - **⏱️ Eval Runtime:** 110070.6349 seconds
45
- - **πŸ“ˆ Eval Samples/Second:** 78.495
46
- - **πŸŒ€ Eval Steps/Second:** 2.453
47
- - **πŸ“‰ Train Loss:** 0.1049
48
- - **⏳ Eval Accuracy:** 94.6%
49
- - **πŸŒ€ Eval Precision:** 94.8%
50
- - **⏱️ Eval Recall:** 94.5%
51
- - **πŸ“ˆ Eval F1 Score:** 94.7%
52
 
53
- ## πŸš€ Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
- You can use this model directly with the Hugging Face `transformers` library:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  ```python
58
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
@@ -74,13 +165,27 @@ emotion = predict_emotion(text)
74
  print("Detected Emotion:", emotion)
75
  ```
76
 
77
- ## πŸ“ Emotion Labels
78
- - 😠 Anger
79
- - 🀒 Disgust
80
- - 😨 Fear
81
- - 😊 Joy
82
- - 😒 Sadness
83
- - 😲 Surprise
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
 
86
  ## πŸ“œ Model Card Data
 
29
  - **πŸ“Š Dataset:** [dair-ai/emotion](https://huggingface.co/dair-ai/emotion)
30
  - **βš™οΈ Fine-tuning:** This model was fine-tuned for emotion detection with a classification head for six emotional categories (anger, disgust, fear, joy, sadness, surprise).
31
 
 
32
 
33
+ ## πŸ“ Emotion Labels
34
+ - 😠 Anger
35
+ - 🀒 Disgust
36
+ - 😨 Fear
37
+ - 😊 Joy
38
+ - 😒 Sadness
39
+ - 😲 Surprise
40
+ -
41
 
42
+ ## πŸš€ Usage
 
 
 
43
 
44
+ You can use this model directly with python package or the Hugging Face `transformers` library:
45
 
 
 
 
 
 
 
 
 
 
46
 
47
+ ### Installation
48
+
49
+ You can install the package using pip:
50
+
51
+ ```bash
52
+ pip install emotionclassifier
53
+ ```
54
+
55
+ ### Basic Usage
56
+
57
+ Here's an example of how to use the `emotionclassifier` to classify a single text:
58
+
59
+ ```python
60
+ from emotionclassifier import EmotionClassifier
61
+
62
+ # Initialize the classifier with the default model
63
+ classifier = EmotionClassifier()
64
+
65
+ # Classify a single text
66
+ text = "I am very happy today!"
67
+ result = classifier.predict(text)
68
+ print("Emotion:", result['label'])
69
+ print("Confidence:", result['confidence'])
70
+ ```
71
+
72
+ ### Batch Processing
73
+
74
+ You can classify multiple texts at once using the `predict_batch` method:
75
+
76
+ ```python
77
+ texts = ["I am very happy today!", "I am so sad."]
78
+ results = classifier.predict_batch(texts)
79
+ print("Batch processing results:", results)
80
+ ```
81
+
82
+ ### Visualization
83
+
84
+ To visualize the emotion distribution of a text:
85
+
86
+ ```python
87
+ from emotionclassifier import plot_emotion_distribution
88
+
89
+ result = classifier.predict("I am very happy today!")
90
+ plot_emotion_distribution(result['probabilities'], classifier.labels.values())
91
+ ```
92
+
93
+ ### CLI Usage
94
+
95
+ You can also use the package from the command line:
96
+
97
+ ```bash
98
+ emotionclassifier --model deberta-v3-small --text "I am very happy today!"
99
+ ```
100
+
101
+ ### DataFrame Integration
102
 
103
+ Integrate with pandas DataFrames to classify text columns:
104
+
105
+ ```python
106
+ import pandas as pd
107
+ from emotionclassifier import DataFrameEmotionClassifier
108
+
109
+ df = pd.DataFrame({
110
+ 'text': ["I am very happy today!", "I am so sad."]
111
+ })
112
+
113
+ classifier = DataFrameEmotionClassifier()
114
+ df = classifier.classify_dataframe(df, 'text')
115
+ print(df)
116
+ ```
117
+
118
+ ### Emotion Trends Over Time
119
+
120
+ Analyze and plot emotion trends over time:
121
+
122
+ ```python
123
+ from emotionclassifier import EmotionTrends
124
+
125
+ texts = ["I am very happy today!", "I am feeling okay.", "I am very sad."]
126
+ trends = EmotionTrends()
127
+ emotions = trends.analyze_trends(texts)
128
+ trends.plot_trends(emotions)
129
+ ```
130
+
131
+ ### Fine-tuning
132
+
133
+ Fine-tune a pre-trained model on your own dataset:
134
+
135
+ ```python
136
+ from emotionclassifier.fine_tune import fine_tune_model
137
+
138
+ # Define your train and validation datasets
139
+ train_dataset = ...
140
+ val_dataset = ...
141
+
142
+ # Fine-tune the model
143
+ fine_tune_model(classifier.model, classifier.tokenizer, train_dataset, val_dataset, output_dir='fine_tuned_model')
144
+ ```
145
+
146
+ ### Using transformers
147
 
148
  ```python
149
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
 
165
  print("Detected Emotion:", emotion)
166
  ```
167
 
168
+ ## πŸ‹οΈ Training
169
+
170
+ The model was trained using the following parameters:
171
+
172
+ - **πŸ”§ Learning Rate:** 2e-5
173
+ - **πŸ“¦ Batch Size:** 4
174
+ - **βš–οΈ Weight Decay:** 0.01
175
+ - **πŸ“… Evaluation Strategy:** Epoch
176
+
177
+ ### πŸ‹οΈ Training Details
178
+
179
+ - **πŸ“‰ Eval Loss:** 0.0858
180
+ - **⏱️ Eval Runtime:** 110070.6349 seconds
181
+ - **πŸ“ˆ Eval Samples/Second:** 78.495
182
+ - **πŸŒ€ Eval Steps/Second:** 2.453
183
+ - **πŸ“‰ Train Loss:** 0.1049
184
+ - **⏳ Eval Accuracy:** 94.6%
185
+ - **πŸŒ€ Eval Precision:** 94.8%
186
+ - **⏱️ Eval Recall:** 94.5%
187
+ - **πŸ“ˆ Eval F1 Score:** 94.7%
188
+
189
 
190
 
191
  ## πŸ“œ Model Card Data