-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRUN_EXPERIMENTS.sh
executable file
·188 lines (156 loc) · 4.72 KB
/
RUN_EXPERIMENTS.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/bin/bash
# Constants
ORIG_DATA_FILE=AffectiveText.Semeval.2007.tar.gz
DATA_DIR=AffectiveText.test
SENTS_FILE=$DATA_DIR/affectivetext.test.data
LABELS_FILE=$DATA_DIR/affectivetext_test.emotions.gold
# Prepare dataset
echo "PREPARING DATASET..."
if [[ ! -f $SENTS_FILE ]]; then
# Extract the dataset, assuming it was already downloaded
tar -xzf $ORIG_DATA_FILE
# Change the xml to a normal text file
head -1001 $DATA_DIR/affectivetext_test.xml | tail -1000 | \
sed 's|^.*id="\([0-9]*\)">\(.*\)</instance>$|\1_\2|g' > $SENTS_FILE
else
echo "Dataset already extracted."
fi
echo ""
############################
# 1) Performance experiments
############################
runExperiments1() {
echo "############################"
echo "# 1) Performance experiments"
echo "############################"
echo ""
TRAIN=100
TEST=900
TRAIN_DATA=data/exp1/train_data.mat
TEST_DATA=data/exp1/test_data.mat
# Preprocess dataset with the values we used in the
# experiments, turning them into 3-D tensors
# (emotion, sentence, bow + label)
echo "BUILDING TENSORS..."
mkdir -p data/exp1
if [[ ! -f data/exp1/train_data.mat ]]; then
python scripts/preprocess.py $SENTS_FILE $LABELS_FILE $TRAIN $TEST \
$TRAIN_DATA $TEST_DATA
else
echo "Tensors already built."
fi
echo ""
# Experiments are here, you can comment thes ones you
# don't want to run.
echo "RUNNING EXPERIMENTS 1..."
mkdir -p results
mkdir -p preds
mkdir -p plots/matrices
if [[ ! -f preds/svm.tsv ]]; then
echo "SVM..."
mkdir -p results/svm
python scripts/svm.py $TRAIN_DATA $TEST_DATA results/svm preds
echo ""
else
echo "SVM results already calculated."
fi
if [[ ! -f preds/single_gp.tsv ]]; then
echo "SINGLE GP..."
mkdir -p results/single_gp
python scripts/single_gp.py $TRAIN_DATA $TEST_DATA results/single_gp preds
echo ""
else
echo "Single GP results already calculated."
fi
#echo "ICM GP COMBINED..."
#mkdir -p results/combined
#python scripts/icm_gp.py $TRAIN_DATA $TEST_DATA results/combined combined
#echo ""
if [[ ! -f preds/combined+.tsv ]]; then
echo "ICM GP COMBINED+..."
mkdir -p results/combined+
python scripts/icm_gp.py $TRAIN_DATA $TEST_DATA results/combined+ preds plots/matrices combined+
echo ""
else
echo "ICM GP COMBINED+ results already calculated."
fi
for i in `seq 5`; do
if [[ ! -f preds/rank_$i.tsv ]]; then
echo "ICM GP RANK $i..."
mkdir -p results/rank_$i
python scripts/icm_gp.py $TRAIN_DATA $TEST_DATA results/rank_$i preds plots/matrices rank $i
echo ""
else
echo "ICM GP RANK $i results already calculated."
fi
done
# Wrap final pearson results and print them in a friendly format
python scripts/print_pearsons.py results > results/final_pearsons.tsv
};
##########################
# 2) Data size experiments
##########################
runExperiments2() {
echo "############################"
echo "# 2) Data size experiments"
echo "############################"
echo ""
TRAIN=900
TEST=100
TRAIN_DATA=data/exp2/train_data.mat
TEST_DATA=data/exp2/test_data.mat
# Preprocess dataset with the values we used in the
# experiments, turning them into 3-D tensors
# (emotion, sentence, bow + label)
echo "BUILDING TENSORS..."
mkdir -p data/exp2
if [[ ! -f data/exp2/train_data.mat ]]; then
python scripts/preprocess.py $SENTS_FILE $LABELS_FILE $TRAIN $TEST \
$TRAIN_DATA $TEST_DATA
else
echo "Tensors already built."
fi
echo ""
echo "RUNNING EXPERIMENTS 2..."
mkdir -p plots
mkdir -p results
if [[ ! -f results/svm_size.tsv ]]; then
echo "SVM..."
python scripts/size.py $TRAIN_DATA $TEST_DATA results svm
echo ""
else
echo "SVM results already calculated."
fi
if [[ ! -f results/single_gp_size.tsv ]]; then
echo "SINGLE GP..."
python scripts/size.py $TRAIN_DATA $TEST_DATA results single_gp
echo ""
else
echo "Single GP results already calculated."
fi
if [[ ! -f results/icm_gp_size.tsv ]]; then
echo "ICM GP RANK 5"
python scripts/size.py $TRAIN_DATA $TEST_DATA results icm_gp rank 5
echo ""
else
echo "ICM GP rank 5 results already calculated."
fi
};
#############################
# 3) Score distribution plots
#############################
runExperiments3() {
if [[ ! -f preds/single_gp.tsv ]]; then
echo "Need to run Experiment 1 first"
else
echo "Plotting score distributions"
mkdir -p plots/dists
TEST_DATA=data/exp1/test_data.mat
python scripts/plot_dists.py $TEST_DATA preds plots/dists
fi
}
# Comment/uncomment as you like. Be aware that runExperiment2
# can take quite a long time.
runExperiments1
#runExperiments2
runExperiments3