Skip to content

Commit d608c80

Browse files
committed
Updated README.md
1 parent 4c9bd4f commit d608c80

File tree

1 file changed

+54
-53
lines changed

1 file changed

+54
-53
lines changed

README.md

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,12 @@ In this repository, we have used the most used features that are available in [l
4242
- Contrast
4343
- Tonnetz (tonal centroid features)
4444

45-
## Algorithms Used
46-
This repository can be used to build machine learning classifiers as well as regressors for the case of 3 emotions {'sad': 0, 'neutral': 1, 'happy': 2} and the case of 5 emotions {'angry': 1, 'sad': 2, 'neutral': 3, 'ps': 4, 'happy': 5}
47-
### Classifiers
48-
- SVC
49-
- RandomForestClassifier
50-
- GradientBoostingClassifier
51-
- KNeighborsClassifier
52-
- MLPClassifier
53-
- BaggingClassifier
54-
- Recurrent Neural Networks (Keras)
55-
### Regressors
56-
- SVR
57-
- RandomForestRegressor
58-
- GradientBoostingRegressor
59-
- KNeighborsRegressor
60-
- MLPRegressor
61-
- BaggingRegressor
62-
- Recurrent Neural Networks (Keras)
63-
6445
## Grid Search
6546
Grid search results are already provided in `grid` folder, but if you want to tune various grid search parameters in `parameters.py`, you can run the script `grid_search.py` by:
6647
```
6748
python grid_search.py
6849
```
69-
This may take several hours to complete execution, once it is finished, results are stored in `grid`.
50+
This may take several hours to complete execution, once it is finished, results are stored in `grid` folder.
7051

7152
## Example 1: Using 3 Emotions
7253
The way to build and train a model for classifying 3 emotions is as shown below:
@@ -119,6 +100,58 @@ print("Prediction:", rec.predict("data/tess_ravdess/validation/Actor_25/25_01_01
119100
Prediction: neutral
120101
Prediction: sad
121102
```
103+
## Example 2: Using RNNs for 5 Emotions
104+
```python
105+
from deep_emotion_recognition import DeepEmotionRecognizer
106+
# initialize instance
107+
# inherited from emotion_recognition.EmotionRecognizer
108+
# default parameters (LSTM: 128x2, Dense:128x2)
109+
deeprec = DeepEmotionRecognizer(emotions=['angry', 'sad', 'neutral', 'ps', 'happy'], n_rnn_layers=2, n_dense_layers=2, rnn_units=128, dense_units=128)
110+
# train the model
111+
deeprec.train()
112+
# get the accuracy
113+
print(deeprec.test_score())
114+
# predict angry audio sample
115+
prediction = deeprec.predict('data/validation/Actor_10/03-02-05-02-02-02-10_angry.wav')
116+
print(f"Prediction: {prediction}")
117+
```
118+
**Output:**
119+
```
120+
0.7948717948717948
121+
Prediction: angry
122+
```
123+
### Confusion Matrix
124+
```python
125+
print(deeprec.confusion_matrix(percentage=True, labeled=True))
126+
```
127+
**Output:**
128+
```
129+
predicted_angry predicted_sad predicted_neutral predicted_ps predicted_happy
130+
true_angry 92.307693 0.000000 1.282051 2.564103 3.846154
131+
true_sad 12.820514 67.948715 3.846154 6.410257 8.974360
132+
true_neutral 3.846154 8.974360 82.051285 2.564103 2.564103
133+
true_ps 2.564103 0.000000 1.282051 83.333328 12.820514
134+
true_happy 20.512821 2.564103 2.564103 2.564103 71.794876
135+
```
136+
## Algorithms Used
137+
This repository can be used to build machine learning classifiers as well as regressors for the case of 3 emotions {'sad': 0, 'neutral': 1, 'happy': 2} and the case of 5 emotions {'angry': 1, 'sad': 2, 'neutral': 3, 'ps': 4, 'happy': 5}
138+
### Classifiers
139+
- SVC
140+
- RandomForestClassifier
141+
- GradientBoostingClassifier
142+
- KNeighborsClassifier
143+
- MLPClassifier
144+
- BaggingClassifier
145+
- Recurrent Neural Networks (Keras)
146+
### Regressors
147+
- SVR
148+
- RandomForestRegressor
149+
- GradientBoostingRegressor
150+
- KNeighborsRegressor
151+
- MLPRegressor
152+
- BaggingRegressor
153+
- Recurrent Neural Networks (Keras)
154+
122155
### Testing
123156
You can test your own voice by executing the following command:
124157
```
@@ -153,39 +186,7 @@ optional arguments:
153186
is "BaggingClassifier"
154187
155188
```
156-
## Example 2: Using RNNs for 5 Emotions
157-
```python
158-
from deep_emotion_recognition import DeepEmotionRecognizer
159-
# initialize instance
160-
# inherited from emotion_recognition.EmotionRecognizer
161-
# default parameters (LSTM: 128x2, Dense:128x2)
162-
deeprec = DeepEmotionRecognizer(emotions=['angry', 'sad', 'neutral', 'ps', 'happy'], n_rnn_layers=2, n_dense_layers=2, rnn_units=128, dense_units=128)
163-
# train the model
164-
deeprec.train()
165-
# get the accuracy
166-
print(deeprec.test_score())
167-
# predict angry audio sample
168-
prediction = deeprec.predict('data/validation/Actor_10/03-02-05-02-02-02-10_angry.wav')
169-
print(f"Prediction: {prediction}")
170-
```
171-
**Output:**
172-
```
173-
0.7948717948717948
174-
Prediction: angry
175-
```
176-
### Confusion Matrix
177-
```python
178-
print(deeprec.confusion_matrix(percentage=True, labeled=True))
179-
```
180-
**Output:**
181-
```
182-
predicted_angry predicted_sad predicted_neutral predicted_ps predicted_happy
183-
true_angry 92.307693 0.000000 1.282051 2.564103 3.846154
184-
true_sad 12.820514 67.948715 3.846154 6.410257 8.974360
185-
true_neutral 3.846154 8.974360 82.051285 2.564103 2.564103
186-
true_ps 2.564103 0.000000 1.282051 83.333328 12.820514
187-
true_happy 20.512821 2.564103 2.564103 2.564103 71.794876
188-
```
189+
189190
## Plotting Histograms
190191
This will only work if grid search is performed.
191192
```python

0 commit comments

Comments
 (0)