Datasets:
1T Conte
commited on
Commit
•
4a223c0
1
Parent(s):
fffa9f9
fix: added balanced datasets
Browse files- README.md +7 -0
- convert.py +15 -0
- positive_negative.csv +3 -0
- positive_negative_balanced.csv +3 -0
README.md
CHANGED
@@ -14,4 +14,11 @@ configs:
|
|
14 |
- split: test
|
15 |
path: "test.csv"
|
16 |
default: true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
---
|
|
|
14 |
- split: test
|
15 |
path: "test.csv"
|
16 |
default: true
|
17 |
+
- config_name: sentiment
|
18 |
+
data_files:
|
19 |
+
- split: complete
|
20 |
+
path: "positive_negative.csv"
|
21 |
+
data_files:
|
22 |
+
- split: balanced
|
23 |
+
path: "positive_negative_balanced.csv"
|
24 |
---
|
convert.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from datetime import datetime
|
|
|
2 |
|
3 |
import pandas as pd
|
4 |
|
@@ -61,6 +62,20 @@ def run():
|
|
61 |
save(test_rows, "test.csv")
|
62 |
save(all_rows, "complete.csv")
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
if __name__ == "__main__":
|
66 |
run()
|
|
|
1 |
from datetime import datetime
|
2 |
+
from random import shuffle
|
3 |
|
4 |
import pandas as pd
|
5 |
|
|
|
62 |
save(test_rows, "test.csv")
|
63 |
save(all_rows, "complete.csv")
|
64 |
|
65 |
+
# Extract only ratings 1, 2, 3, and 4 (negative reviews), and also
|
66 |
+
# ratings 7, 8, 9, and 10 (positive reviews)
|
67 |
+
negative_rows = [row for row in all_rows if row["rating"] <= 4]
|
68 |
+
positive_rows = [row for row in all_rows if row["rating"] >= 7]
|
69 |
+
positive_negative_rows = negative_rows + positive_rows
|
70 |
+
shuffle(positive_negative_rows)
|
71 |
+
save(positive_negative_rows, "positive_negative.csv")
|
72 |
+
|
73 |
+
# Balance the dataset
|
74 |
+
min_size = min(len(negative_rows), len(positive_rows))
|
75 |
+
balanced_rows = negative_rows[:min_size] + positive_rows[:min_size]
|
76 |
+
shuffle(balanced_rows)
|
77 |
+
save(balanced_rows, "positive_negative_balanced.csv")
|
78 |
+
|
79 |
|
80 |
if __name__ == "__main__":
|
81 |
run()
|
positive_negative.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ec6b3ee0b25857f5e6bb83e55b3da85e3304aeaf3796de72aef5cb8ba5549f3b
|
3 |
+
size 97868615
|
positive_negative_balanced.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a7d3030fe9ea8d256276dd52cc7ecffc6985b748447f6c78690bde23cbfb410b
|
3 |
+
size 53051421
|