-
Notifications
You must be signed in to change notification settings - Fork 1
/
Run.sh
executable file
·498 lines (443 loc) · 13.9 KB
/
Run.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
#!/bin/bash -e
echo
echo 'WELCOME TO THE PREDICTIVE WORLD '
echo
echo
cd $HOME
code_directory=$IDCODE
# echo "Current path is : $code_directory"
#chnaging and storing path
cd $code_directory
curr_location=$(<$code_directory/filelocation.txt)
cd ./src
## IT will check if you are running on travis CI then you
## Coverage run to get generate report else python3
string=$IDCODE
if [[ $string == *"travis"* ]];
then
runVar='coverage run'
else
runVar='python3'
fi
error_criteria=0.05 #Tree:erroe based clustering criteria
significance_level=0.05 #significance level
max_iter=100
elimination="False" #elimination default set as Flase
limited_ref_points="False"
method="common"
process="general"
num_clusters=2
##################################################
## List of arguments in the
##################################################
ARGUMENT_LIST=(
"algo"
"train"
"test"
"trainO"
"testO"
"sfile"
"c"
"b"
"a"
"i"
"h"
"m"
"e"
"k"
"f"
"n"
"p"
"r"
"s"
"d"
"o"
"l"
)
# read arguments
opts=$(getopt \
--longoptions "$(printf "%s:," "${ARGUMENT_LIST[@]}")" \
--name "$(basename "$0")" \
--options "" \
-- "$@"
)
eval set --$opts
#$# will number of arguments passed
#run till all arnuments passed
num=$(( ($#-1)/2 )) #defined variable to stoe number of flags passed
# if not argument is passed then show them commands
if(($num == 0))
then
echo ""
echo "No argument passed : "
echo " --algo : Select algorithm Multiple regression, Spath, GMM, Error based tree"
echo " --train : Select algorithm Multiple regression, Spath, GMM, Error based tree"
echo " --test : Select algorithm Multiple regression, Spath, GMM, Error based tree"
echo " --trainO : Select algorithm Multiple regression, Spath, GMM, Error based tree"
echo " --testO : Select algorithm Multiple regression, Spath, GMM, Error based tree"
echo " --sfile : Select algorithm Multiple regression, Spath, GMM, Error based tree"
echo " --c : Critria for error based clustering"
echo " --l : Limit of number of refrence point"
echo " --b : Bond analysis in the Fuel "
echo " --a : Analysis for fuel parameters"
echo " --i : Maximum number of iteration"
echo " --n : Maximum number of cluster"
echo " --h : Histogram Plots"
echo " --f : Plot histogram of all the result"
echo " --k : External fuel analysis saving all the result"
echo " --p : plotting of coefficient to find Average values"
echo " --r : Backward elimination Activation True/False"
echo " --s : Significance Level for Backward Elimination"
echo " --d : Dataset generation ONLY for fuel contaning SMILES"
echo ""
exit
fi
while [ $num -gt 0 ]; do
case "$1" in
# define methods over here
"--algo")
method=$2 #which algorithm to execute
echo "Reading the algorithm :"$method
shift 2
;;
"--train")
dataset_location="$curr_location/"$2
echo "Reading the data location :"$dataset_location
process="train"
shift 2
;;
"--test")
dataset_location="$curr_location/"$2
echo "Reading the data location :"$dataset_location
process="test"
shift 2
;;
"--trainO")
dataset_location="$curr_location/"$2
echo "Reading the data location :"$dataset_location
process="trainO"
shift 2
;;
"--testO")
dataset_location="$curr_location/"$2
echo "Reading the data location :"$dataset_location
process="testO"
shift 2
;;
# define general or other flags over here
--b)
flag_passed='-b'
fuel_SMILE=$2
echo "Type of Bonds in $fuel_SMILE : "
shift 2
;;
--c)
error_criteria=$2
echo "Defined criterion for error based clustering : $error_criteria "
echo
shift 2
;;
--i)
max_iter=$2
echo "Maximum iterations : $error_criteria "
echo
shift 2
;;
--n)
num_clusters=$2
echo "Number of clusters : $num_clusters "
echo
shift 2
;;
--a)
flag_passed='-a'
echo "Manual Analysis of fuel-dataset given range of parameter:"
analysis_type=$2
shift 2
;;
--"sfile")
echo "Analysis of file given:"
dataset_location="$curr_location/$2"
echo $dataset_location
shift 2
;;
--h)
flag_passed='-h'
echo "Histogram plots of parameters:"
dataset_location="$curr_location/"$2
echo
shift 2
;;
--k)
flag_passed='-k'
echo "External Data passsed to predict the Ignition Delay and to store result seperately"
dataset_location="$curr_location/"$2
echo
shift 2
;;
--f)
flag_passed='-f'
echo "Plotting of all test result"
dataset_location="$curr_location/"$2
echo
shift 2
;;
--p)
flag_passed='-p'
echo "Plot of average coeffcient value obtained by histogram of coeffcients"
dataset_location="$curr_location/"$2
echo $dataset_location
echo
shift 2
;;
--r)
flag_passed='-r'
echo "Eliminiation of feature set as True"
elimination=$2
echo
shift 2
;;
--l)
flag_passed='-l'
echo "Refrence Points are limited by features"
limited_ref_points=$2
echo $limited_ref_points
shift 2
;;
--s)
flag_passed='-s'
significance_level=$2
echo "Significance level for backward elimination : $significance_level"
echo
shift 2
;;
--d)
flag_passed='-d'
echo 'Generating dataset with transformed feature'
dataset_location="$curr_location/"$2
echo
shift 2
;;
*)
echo ""
echo "Wrong argument passed : "
echo " --algo : Select algorithm Multiple regression, Spath, GMM, Error based tree"
echo " --train : Select algorithm Multiple regression, Spath, GMM, Error based tree"
echo " --test : Select algorithm Multiple regression, Spath, GMM, Error based tree"
echo " --trainO : Select algorithm Multiple regression, Spath, GMM, Error based tree"
echo " --testO : Select algorithm Multiple regression, Spath, GMM, Error based tree"
echo " --sfile : Select algorithm Multiple regression, Spath, GMM, Error based tree"
echo " --c : Critria for error based clustering"
echo " --l : Limit of number of refrence point"
echo " --b : Bond analysis in the Fuel "
echo " --a : Analysis for fuel parameters"
echo " --i : Maximum number of iteration"
echo " --n : Maximum number of cluster"
echo " --h : Histogram Plots"
echo " --f : Plot histogram of all the result"
echo " --k : External fuel analysis saving all the result"
echo " --p : plotting of coefficient to find Average values"
echo " --r : Backward elimination Activation True/False"
echo " --s : Significance Level for Backward Elimination"
echo " --d : Dataset generation ONLY for fuel contaning SMILES"
echo ""
break
;;
esac
num=$((num-1)) #reducing flag value
done
########################################################
################Common Function or Ploting #############
########################################################
plotting_fucntion () {
#moving to plots folder
cd "$curr_location/plots/"
#gnerating pdf from tex file
# pdflatex Training.tex > /dev/null 2>&1 #to not print output
#opeing the pdf file
# xdg-open Training.pdf
echo 'Plotting of Training done'
# pdflatex Testing.tex > /dev/null 2>&1
# xdg-open Testing.pdf
# echo 'Plotting of Testing done'
# pdflatex Datasize.tex > /dev/null 2>&1
# xdg-open Datasize.pdf
echo 'Plotting of Datasize done'
# pdflatex MaxRelError.tex > /dev/null 2>&1
# xdg-open MaxRelError.pdf
echo 'Plotting of MaxRelError done'
# pdflatex ChildLabel.tex > /dev/null 2>&1
# xdg-open ChildLabel.pdf
echo 'Plotting of Labels done'
cd
cd $code_directory
cd ./src/tree
$runVar coef_tikz_compatible.py "$curr_location/plots/"
# $runVar Fuel_tikz_compatible.py "$curr_location/plots/"
dir_to_plot="$curr_location/plots/"
cd $dir_to_plot
# pdflatex coefficient.tex > /dev/null 2>&1
# xdg-open coefficient.pdf
echo 'Plotting of Coefficients done'
#in plotting dir, deleting all files except .pdf
find $dir_to_plot -name '*.aux' -delete
find $dir_to_plot -name '*.tex' -delete
find $dir_to_plot -name '*.log' -delete
# pdflatex FuelsTrainingTesting.tex > /dev/null 2>&1
# xdg-open FuelsTrainingTesting.pdf
}
# ###############################################
# #BASED ON FLAG, IT WILL RUN THE $runVar SCRIPT#
# ###############################################
if [ $method == 'common' ]
then
echo "Working on common methods"
##Analysis of fuel dataset
if [ $flag_passed == '-a' ]
then
if [ $analysis_type == 'manual' ]
then
$runVar DDS.py -a $method $process $dataset_location $curr_location $analysis_type
fi
if [ $analysis_type == 'temperature' ]
then
$runVar DDS.py -a $method $process $dataset_location $curr_location $analysis_type
fi
if [ $analysis_type == 'pressure' ]
then
$runVar DDS.py -a $method $process $dataset_location $curr_location $analysis_type
fi
if [ $analysis_type == 'parameter' ]
then
$runVar DDS.py -a $method $process $dataset_location $curr_location $analysis_type
fi
if [ $analysis_type == 'distribution' ]
then
$runVar DDS.py -a $method $process $dataset_location $curr_location $analysis_type
fi
fi
if [ $flag_passed == '-d' ]
then
$runVar DDS.py -d $method $process $dataset_location $curr_location
fi
if [ $flag_passed == '-b' ]
then
$runVar DDS.py -b $method $process $fuel_SMILE $curr_location #SMILE will passed in place of dataset location
fi
##Histogram plots of data
if [ $flag_passed == '-h' ]
then
$runVar DDS.py -h $method $process $dataset_location $curr_location
fi
#################################
#################################
#other than fuel data set if dataset
#ready you just want to generate model
#feature selection will be different
if [ $flag_passed == '-k' ]
then
$runVar DDS.py -k $method $process $dataset_location $curr_location
echo 'done'
fi
if [ $flag_passed == '-f' ]
then
$runVar DDS.py -f $method $process $dataset_location $curr_location
echo 'done'
fi
if [ $flag_passed == '-p' ]
then
$runVar DDS.py -p $method $process $dataset_location $curr_location
echo 'done'
fi
fi
#################################################################################
#flag in methods are of no use it is just there to keep consistency in the format
#################################################################################
if [ $method == 'GMM' ]
then
if [ $process == 'train' ]
then
echo 'GMM'
#removing old directory
rm -rf "$curr_location/object_file"
rm -rf "$curr_location/plots"
echo "Generating cluster using GMM"
$runVar DDS.py -t $method $process $dataset_location $curr_location $num_clusters $max_iter $limited_ref_points
# plotting_fucntion
fi
if [ $process == 'test' ]
then
#removing old directory
echo "Testing the model using GMM"
$runVar DDS.py -e $method $process $dataset_location $curr_location
# plotting_fucntion
fi
fi
if [ $method == 'tree' ]
then
if [ $process == 'train' ]
then
echo 'tree'
#removing old directory
rm -rf "$curr_location/object_file"
rm -rf "$curr_location/plots"
echo "Generate cluster and Training/Testing the model based on tree"
$runVar DDS.py -t $method $process $dataset_location $curr_location $error_criteria $elimination $significance_level $limited_ref_points
# plotting_fucntion
fi
if [ $process == 'test' ]
then
#removing old directory
echo "Generate cluster and Training/Testing the model based on tree"
$runVar DDS.py -e $method $process $dataset_location $curr_location
# plotting_fucntion
fi
fi
if [ $method == 'spath' ]
then
if [ $process == 'train' ]
then
echo 'tree'
#removing old directory
rm -rf "$curr_location/object_file"
rm -rf "$curr_location/plots"
echo "Generate cluster and Training/Testing the model based on Spath"
$runVar DDS.py -t $method $process $dataset_location $curr_location $num_clusters $max_iter $limited_ref_points
# plotting_fucntion
fi
if [ $process == 'test' ]
then
#removing old directory
echo "Generate cluster and Training/Testing the model based on Spath"
$runVar DDS.py -e $method $process $dataset_location $curr_location
# plotting_fucntion
fi
fi
if [ $method == 'multi' ]
then
if [ $process == 'train' ]
then
echo 'tree'
#removing old directory
rm -rf "$curr_location/object_file"
rm -rf "$curr_location/plots"
echo "Running Multiple Linear Regression:"
$runVar DDS.py -m $method $process $dataset_location $curr_location $elimination $significance_level
# plotting_fucntion
fi
if [ $process == 'test' ]
then
#removing old directory
echo "Generate cluster and Training/Testing the model based on Spath"
$runVar DDS.py -e $method $process $dataset_location $curr_location
# plotting_fucntion
fi
fi
echo
echo
echo
echo "Processs Completed!! "
cd
cd $code_directory
#removing file
rm filelocation.txt