Showing
26 changed files
with
124 additions
and
0 deletions
CRF/bin/FIG1.png
0 → 100644

93.2 KB
CRF/bin/figures-report.py
0 → 100644
1 | +from optparse import OptionParser | ||
2 | +import re | ||
3 | +from collections import defaultdict as df | ||
4 | +import os | ||
5 | +import random | ||
6 | +from pandas import DataFrame as DF | ||
7 | +import matplotlib.pyplot as plt | ||
8 | + | ||
9 | +# Objective | ||
10 | +# Drawn figures of grid reports | ||
11 | +# | ||
12 | +# Input parameters | ||
13 | +# --inputPath=PATH Path of inputfiles | ||
14 | +# --outputPath=PATH Path to place output figures | ||
15 | +# --figureName single run specific name figure, multifigure first part of name | ||
16 | +# --inputFile Use it for a single report | ||
17 | +# --version CRF-script version of reports | ||
18 | +# | ||
19 | +# Output | ||
20 | +# training and test data set | ||
21 | +# | ||
22 | +# Examples | ||
23 | +# python figures-reports.py | ||
24 | +# --inputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/reports/ | ||
25 | +# --outputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/figures/ | ||
26 | +# --figureName FiguresGrid | ||
27 | +# --inputFile report_Run1_v11.txt | ||
28 | +# -version v11 | ||
29 | + | ||
30 | +# python figures-reports.py --inputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/reports/ --outputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/figures/ --figureName FiguresGrid_v1 --inputFile report_Run1_v11.txt ..version v11 | ||
31 | +__author__ = 'egaytan' | ||
32 | + | ||
33 | +#################################################################################### | ||
34 | +# FUNCTIONS # | ||
35 | +#################################################################################### | ||
36 | +def Filter(rfile, options,v): | ||
37 | + if options[0]=='all': | ||
38 | + if rfile[0:6]=='report' and rfile[-7:-4]==v: return(True) | ||
39 | + elif rfile in options: | ||
40 | + return(True) | ||
41 | + return(False) | ||
42 | + | ||
43 | +#################################################################################### | ||
44 | +# MAIN PROGRAM # | ||
45 | +#################################################################################### | ||
46 | + | ||
47 | +if __name__ == '__main__': | ||
48 | + # Defining parameters | ||
49 | + parser = OptionParser() | ||
50 | + parser.add_option('--inputPath', dest='inputPath', help='Path of output from CoreNLP', metavar='PATH') | ||
51 | + parser.add_option('--outputPath', dest='outputPath', help='Path to place output figures', metavar='PATH') | ||
52 | + parser.add_option('--figureName', dest='figureName', help='Specific or first part of figurename', metavar='FILE') | ||
53 | + parser.add_option('--version', dest='version', help='script version', metavar='FILE') | ||
54 | + parser.add_option('--inputFile', dest='inputFile', help='Use it for a specific report files', metavar='FILE', default='all,') | ||
55 | + | ||
56 | + (options, args) = parser.parse_args() | ||
57 | + if len(args) > 0: | ||
58 | + parser.error('Any parameter given.\nFor multi input files be sure to seprate the filenames by coma') | ||
59 | + sys.exit(1) | ||
60 | + | ||
61 | + print('-------------------------------- PARAMETERS --------------------------------') | ||
62 | + print('Path of output from CoreNLP: ' + str(options.inputPath)) | ||
63 | + print('Path to place output figures: ' + str(options.outputPath)) | ||
64 | + print('Specific or first part of figurename: ' + str(options.figureName)) | ||
65 | + print('CRF-script version: ' + str(options.version)) | ||
66 | + | ||
67 | + print('-------------------------------- PROCESSING --------------------------------') | ||
68 | + | ||
69 | + rawInputRepotsList = str(options.inputFile).split(',') | ||
70 | + reportFileList = [ rfile for rfile in os.listdir(options.inputPath) if Filter(rfile, rawInputRepotsList, str(options.version)) ] | ||
71 | + scores = df(dict) | ||
72 | + #CV={} | ||
73 | + print('Report files: ' + str(options.inputFile )) | ||
74 | + print('\n'.join(reportFileList)) | ||
75 | + print('----------------------------------- NOTE -----------------------------------') | ||
76 | + print('\n-------- All chosen report files should be in inputPath given---------------\n') | ||
77 | + | ||
78 | + print('------------------------------- SAVING DATA --------------------------------\n') | ||
79 | + for report in reportFileList: | ||
80 | + with open(os.path.join(options.inputPath, report), 'r') as File: | ||
81 | + string = File.read() | ||
82 | + scores[report[7:11]]['CV']=re.findall('best\sCV\sscore\:(\d+\.\d+)', string)[0] | ||
83 | + summaryScores = re.findall('avg\s\/\stotal\s+(\d+\.\d+)\s+(\d+\.\d+)\s+(\d+\.\d+)', string)[0] | ||
84 | + scores[report[7:11]]['precision']=summaryScores[0] | ||
85 | + scores[report[7:11]]['recall']=summaryScores[1] | ||
86 | + scores[report[7:11]]['f1-score']=summaryScores[2] | ||
87 | + | ||
88 | + print(DF(scores).T) | ||
89 | + scoresTable = DF(scores).T | ||
90 | + | ||
91 | + imageName=os.path.join(options.outputPath, options.figureName) | ||
92 | + ylab = "score", | ||
93 | + fig = plt.figure() | ||
94 | + plt.grid(False) | ||
95 | + plt.rcParams.update({'font.size': 15}) | ||
96 | + fig.set_figheight(13) | ||
97 | + fig.set_figwidth(20) | ||
98 | + plt.xlabel("Runs") | ||
99 | + plt.ylabel("score") | ||
100 | + plt.xticks(range(8),scoresTable["CV"].index) | ||
101 | + plt.plot(scoresTable['CV'], "--", color="red", label="CV") | ||
102 | + plt.plot(scoresTable['precision'], color="blue", label="precision") | ||
103 | + plt.plot(scoresTable['f1-score'], color="orange", label="F1") | ||
104 | + plt.plot(scoresTable['recall'], color="g", label="recall") | ||
105 | + plt.legend(loc='lower right') | ||
106 | + plt.tight_layout() | ||
107 | + fig.savefig(imageName, pad_inches=0.5) | ||
108 | + | ||
109 | + | ||
110 | + | ||
111 | + | ||
112 | + | ||
113 | + |
CRF/bin/grid_v10.sh
0 → 100644
1 | + | ||
2 | +python3 training_validation_v10.py --inputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/data-sets --trainingFile training-data-set-70.txt --testFile test-data-set-30.txt --outputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/ --Gridname Run1 --version _v10 > ../outputs/Run1_v10.txt | ||
3 | +python3 training_validation_v10.py --inputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/data-sets --trainingFile training-data-set-70.txt --testFile test-data-set-30.txt --outputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/ --Gridname Run2 --version _v10 --S1 > ../outputs/Run2_v10.txt | ||
4 | +python3 training_validation_v10.py --inputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/data-sets --trainingFile training-data-set-70.txt --testFile test-data-set-30.txt --outputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/ --Gridname Run3 --version _v10 --S2 > ../outputs/Run3_v10.txt | ||
5 | +python3 training_validation_v10.py --inputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/data-sets --trainingFile training-data-set-70.txt --testFile test-data-set-30.txt --outputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/ --Gridname Run4 --version _v10 --S1 --S2 > ../outputs/Run4_v10.txt | ||
6 | +python3 training_validation_v10.py --inputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/data-sets --trainingFile training-data-set-70.txt --testFile test-data-set-30.txt --outputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/ --Gridname Run5 --version _v10 --S3 > ../outputs/Run5_v10.txt | ||
7 | +python3 training_validation_v10.py --inputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/data-sets --trainingFile training-data-set-70.txt --testFile test-data-set-30.txt --outputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/ --Gridname Run6 --version _v10 --S1 --S3 > ../outputs/Run6_v10.txt | ||
8 | +python3 training_validation_v10.py --inputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/data-sets --trainingFile training-data-set-70.txt --testFile test-data-set-30.txt --outputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/ --Gridname Run7 --version _v10 --S2 --S3 > ../outputs/Run7_v10.txt | ||
9 | +python3 training_validation_v10.py --inputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/data-sets --trainingFile training-data-set-70.txt --testFile test-data-set-30.txt --outputPath /home/egaytan/automatic-extraction-growth-conditions/CRF/ --Gridname Run8 --version _v10 --S1 --S2 --S3 > ../outputs/Run8_v10.txt | ||
10 | + | ||
11 | + |
File moved
CRF/figures/FiguresGrid_v10.png
0 → 100644

114 KB
CRF/figures/FiguresGrid_v11.png
0 → 100644

123 KB
CRF/models/model_S1_False_S2_False_v10.mod
0 → 100644
No preview for this file type
CRF/models/model_S1_False_S2_True_v10.mod
0 → 100644
No preview for this file type
CRF/models/model_S1_True_S2_False_v10.mod
0 → 100644
No preview for this file type
CRF/models/model_S1_True_S2_True_v10.mod
0 → 100644
No preview for this file type
CRF/outputs/Run1_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/outputs/Run2_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/outputs/Run3_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/outputs/Run4_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/outputs/Run5_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/outputs/Run6_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/outputs/Run7_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/outputs/Run8_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/reports/report_Run1_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/reports/report_Run2_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/reports/report_Run3_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/reports/report_Run4_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/reports/report_Run5_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/reports/report_Run6_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/reports/report_Run7_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
CRF/reports/report_Run8_v10.txt
0 → 100644
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment