-
Notifications
You must be signed in to change notification settings - Fork 2
/
experiments.py
580 lines (510 loc) · 24.3 KB
/
experiments.py
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
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
"""
Module containing methods for experimenting with the various graph representations.
Experiments not particular to any single representation is put here,
e.g. comparisons of the representations , or tests of properties of the datasets.
"""
import pprint as pp
import numpy
import scipy.spatial.distance
import data
import graph
import freq_representation
import graph_representation
import evaluation
import plotter
import preprocess
numpy.set_printoptions(linewidth = 1000, precision = 3)
def classification_comparison_graph(dataset='reuters', graph_type='co-occurrence', icc=None):
"""
Experiment used for comparative evaluation of different network
representations on classification.
graph_type = 'co-occurrence' | 'dependency'
`icc` determines whether to use _inverse corpus centrality_ in the vector representations.
"""
import co_occurrence_experiments
import dependency_experiments
def make_dicts(docs, icc):
rep = []
for i, doc in enumerate(docs):
if i%100==0: print ' graph',str(i)+'/'+str(len(docs))
g = gfuns[graph_type](doc)
d = graph_representation.graph_to_dict(g, metrics[graph_type], icc)
rep.append(d)
return rep
postfix = {'co-occurrence':'_text', 'dependency':'_dependencies'}
gfuns = {'co-occurrence':graph_representation.construct_cooccurrence_network,
'dependency':graph_representation.construct_dependency_network}
metrics = {'co-occurrence':graph.GraphMetrics.WEIGHTED_DEGREE,
'dependency':graph.GraphMetrics.CLOSENESS}
print '--', graph_type
print '> Reading data..', dataset
training_path = '../data/'+dataset+'/training'+postfix[graph_type]
training_docs, training_labels = data.read_files(training_path)
test_path = '../data/'+dataset+'/test'+postfix[graph_type]
test_docs, test_labels = data.read_files(test_path)
icc_training = None
icc_test = None
if icc:
print '> Calculating ICC..'
if graph_type is 'co-occurrence':
icc_training = co_occurrence_experiments.retrieve_centralities(dataset+'/training', 'sentence', metrics[graph_type])
elif graph_type is 'dependency':
icc_training = dependency_experiments.retrieve_centralities(dataset+'/training', metrics[graph_type])
if graph_type is 'co-occurrence':
icc_test = co_occurrence_experiments.retrieve_centralities(dataset+'/test', 'sentence', metrics[graph_type])
elif graph_type is 'dependency':
icc_test = dependency_experiments.retrieve_centralities(dataset+'/test', metrics[graph_type])
print '> Creating representations..'
training_dicts = make_dicts(training_docs, icc_training)
test_dicts = make_dicts(test_docs, icc_test)
print ' dicts -> vectors'
keys = set()
for d in training_dicts + test_dicts:
keys = keys.union(d.keys())
keys = list(keys)
print ' vocabulary size:', len(keys)
training_rep = graph_representation.dicts_to_vectors(training_dicts, keys)
test_rep = graph_representation.dicts_to_vectors(test_dicts, keys)
print '> Evaluating..'
reps = {'training':training_rep, 'test':test_rep}
labels = {'training':training_labels, 'test':test_labels}
results = evaluation.evaluate_classification(reps, labels, mode='split')
print results
s = 'classification comparison '
if icc: s += 'USING TC-ICC'
s += '\nrepresentation: '+graph_type+'\nresult: '+str(results)+'\n\n\n'
data.write_to_file(s, 'output/comparison/classification')
return results
def classification_comparison_freq(dataset='reuters'):
print '> Reading data..', dataset
training_path = '../data/'+dataset+'/training_preprocessed'
training_docs, training_labels = data.read_files(training_path)
test_path = '../data/'+dataset+'/test_preprocessed'
test_docs, test_labels = data.read_files(test_path)
results = {}
for metric in freq_representation.get_metrics():
print ' ', metric,
training_dicts = freq_representation.text_to_dict(training_docs, metric)
test_dicts = freq_representation.text_to_dict(test_docs, metric)
print ' dicst -> vectors'
keys = set()
for d in training_dicts + test_dicts:
keys = keys.union(d.keys())
print ' vocabulary size:', len(keys)
training_rep = graph_representation.dicts_to_vectors(training_dicts, keys)
test_rep = graph_representation.dicts_to_vectors(test_dicts, keys)
reps = {'training':training_rep, 'test':test_rep}
labels = {'training':training_labels, 'test':test_labels}
score = evaluation.evaluate_classification(reps, labels, mode='split')
results[metric] = score
print score
pp.pprint(results)
s = 'classification comparison \nrepresentation: frequency\nresult:\n'+str(results)+'\n\n\n'
data.write_to_file(s, 'output/comparison/classification')
return results
def retrieval_comparison_graph(dataset='air', graph_type='co-occurrence', use_icc=False):
"""
Experiment used for comparative evaluation of different network
representations on retrieval.
graph_type = 'co-occurrence' | 'dependency'
`icc` determines whether to use _inverse corpus centrality_ in the vector representations.
"""
def make_dicts(docs, icc=None):
rep = []
for i, doc in enumerate(docs):
if i%100==0: print ' graph',str(i)+'/'+str(len(docs))
g = gfuns[graph_type](doc)
d = graph_representation.graph_to_dict(g, metrics[graph_type], icc)
rep.append(d)
return rep
postfix = {'co-occurrence':'_text', 'dependency':'_dependencies'}
gfuns = {'co-occurrence':graph_representation.construct_cooccurrence_network,
'dependency':graph_representation.construct_dependency_network}
metrics = {'co-occurrence':graph.GraphMetrics.WEIGHTED_DEGREE,
'dependency':graph.GraphMetrics.EIGENVECTOR}
print '--', graph_type
print '> Reading data..', dataset
path = '../data/'+dataset+'/problem_descriptions'+postfix[graph_type]
docs, labels = data.read_files(path)
print '> Creating solution representations..'
solutions_path = '../data/'+dataset+'/solutions_preprocessed'
solutions_texts, labels = data.read_files(solutions_path)
solutions_rep = freq_representation.text_to_vector(solutions_texts, freq_representation.FrequencyMetrics.TF_IDF)
icc = None
if use_icc:
print '> Calculating ICC..'
m = metrics[graph_type].split()[0]
print graph_type
if graph_type == 'co-occurrence':
p = 'output/centralities/co-occurrence/'+dataset+'/problem_descriptions/window/'+m+'.cent'
elif graph_type == 'dependency':
p = 'output/centralities/dependency/'+dataset+'/problem_descriptions/'+m+'.cent'
print ' fetching', p
icc = data.pickle_from_file(p)
print ' icc:', type(icc)
print '> Creating problem description representations..'
dicts = make_dicts(docs, icc)
descriptions_rep = graph_representation.dicts_to_vectors(dicts)#, remove_stop_words=True)
print '> Evaluating..'
results = evaluation.evaluate_retrieval(descriptions_rep, solutions_rep)
print results
s = 'retrieval comparison '
if use_icc: s += 'USING TC-ICC'
s += '\nrepresentation: '+graph_type+'\nresult: '+str(results)+'\n\n\n'
data.write_to_file(s, 'output/comparison/retrieval')
return results
def retrieval_comparison_freq(dataset='mir'):
print '> Reading data..', dataset
path = '../data/'+dataset+'/problem_descriptions_preprocessed'
docs, _ = data.read_files(path)
print '> Creating solution representations..'
solutions_path = '../data/'+dataset+'/solutions_preprocessed'
solutions_docs, _ = data.read_files(solutions_path)
solutions_rep = freq_representation.text_to_vector(solutions_docs, freq_representation.FrequencyMetrics.TF_IDF)
print '> Evaluating..'
results = {}
for metric in freq_representation.get_metrics():
print ' ', metric,
descriptions_rep = freq_representation.text_to_vector(docs, metric)
score = evaluation.evaluate_retrieval(descriptions_rep, solutions_rep)
results[metric] = score
print score
pp.pprint(results)
s = 'retrieval comparison \nrepresentation: frequency\ndataset:'+dataset+' \nresult:\n'+str(results)+'\n\n\n'
data.write_to_file(s, 'output/comparison/retrieval')
return results
def do_classification_experiments(dataset='tasa/TASA900',
graph_types = ['co-occurrence','dependency','random'],
use_frequency = True):
"""
Experiment used for comparative evaluation of different network
representations on classification.
Toggle comparison with frequency-based methods using *use_frequency*.
"""
results = {'_dataset':dataset,
'_evaluation':'classification'}
print '> Evaluation type: classification'
print '> Reading data..', dataset
corpus_path = '../data/'+dataset
docdata = data.read_data(corpus_path, graph_types)
print '> Evaluating..'
for gtype in graph_types:
print ' ',gtype
documents, labels = docdata[gtype]
graphs = graph_representation.create_graphs(documents, gtype)
results[gtype] = {}
for metric in graph_representation.get_metrics():
print ' -', metric
vectors = graph_representation.graphs_to_vectors(graphs, metric)
results[gtype][metric] = evaluation.evaluate_classification(vectors, labels)
if use_frequency:
print ' frequency'
results['freq'] = {}
for metric in freq_representation.get_metrics():
print ' -', metric
documents, labels = data.read_files(corpus_path+'_preprocessed')
vectors = freq_representation.text_to_vector(documents, metric)
results['freq'][metric] = evaluation.evaluate_classification(vectors, labels)
print
pp.pprint(results)
return results
def freq_classification(dataset='tasa/TASA900'):
results = {'_dataset':dataset,
'_evaluation':'classification'}
corpus_path = '../data/'+dataset
results['results'] = {}
for metric in freq_representation.get_metrics():
print metric
documents, labels = data.read_files(corpus_path+'_preprocessed')
vectors = freq_representation.text_to_vector(documents, metric)
r = evaluation.evaluate_classification(vectors, labels, mode='cross-validation')
results['results'][metric] = r
print ' ', r
print
pp.pprint(results)
return results
def do_retrieval_experiments(descriptions='air/problem_descriptions',
solutions='air/solutions',
graph_types=['co-occurrence','dependency','random'],
use_frequency=True):
"""
Experiment used for comparative evaluation of different network
representations on the retrieval task.
Toggle comparison with frequency-based methods using *use_frequency*.
"""
results = {'_solutions':solutions,
'_descriptions':descriptions,
'_evaluation':'retrieval'}
print '> Evaluation type: retrieval'
print '> Reading cases..'
descriptions_path = '../data/'+descriptions
descriptiondata = data.read_data(descriptions_path, graph_types)
solutions_path = '../data/'+solutions+'_preprocessed'
solution_texts, labels = data.read_files(solutions_path)
solution_vectors = freq_representation.text_to_vector(solution_texts, freq_representation.FrequencyMetrics.TF_IDF)
print '> Evaluating..'
for gtype in graph_types:
print ' ',gtype
docs, labels = descriptiondata[gtype]
graphs = graph_representation.create_graphs(docs, gtype)
results[gtype] = {}
for metric in graph_representation.get_metrics():
print ' -', metric
vectors = graph_representation.graphs_to_vectors(graphs, metric)
results[gtype][metric] = evaluation.evaluate_retrieval(vectors, solution_vectors)
if use_frequency:
print ' frequency'
results['freq'] = {}
for metric in freq_representation.get_metrics():
print ' -', metric
docs, labels = data.read_files(descriptions_path+'_preprocessed')
vectors = freq_representation.text_to_vector(docs, metric)
results['freq'][metric] = evaluation.evaluate_retrieval(vectors, solution_vectors)
print
pp.pprint(results)
return results
def plot_sentence_lengths(datafile=None):
"""
Function for plotting histogram of sentence lengths within a given dataset.
"""
if datafile is None:
import preprocess
print '> reading data..'
path = '../data/tasa/TASA900_text'
texts, labels = data.read_files(path)
sentence_lengths = []
print '> counting lengths..'
for text in texts:
sentences = preprocess.tokenize_sentences(text)
for sentence in sentences:
tokens = preprocess.tokenize_tokens(sentence)
sentence_lengths.append(len(tokens))
data.pickle_to_file(sentence_lengths, 'output/tasa_sentence_lengths.pkl')
else:
sentence_lengths = data.pickle_from_file(datafile)
plotter.histogram(sentence_lengths, 'sentence length (tokens)', '# sentences', bins=70)
def print_network_props():
"""
Prints latex table with various properties for networks created from
texts in the datasets.
"""
print '-- Co-occurrence'
tasa = data.pickle_from_file('output/properties/cooccurrence/stats_tot_tasa.TASA900')
air = data.pickle_from_file('output/properties/cooccurrence/stats_tot_air.problem_descriptions')
for key in air.keys():
prop, sep, mod = key.partition('_')
if mod!='std':
print prop,' & ',
print '%2.3f'%tasa[prop+sep+'mean'],' & ','%2.3f'%tasa[prop+sep+'std'],' & ',
print '%2.3f'%air[prop+sep+'mean'],' & ','%2.3f'%air[prop+sep+'std'],'\\\\'
print
print '-- Dependency, all types'
air = data.pickle_from_file('output/properties/dependency/stats_tot_air.problem_descriptions')
tasa = data.pickle_from_file('output/properties/dependency/stats_tot_tasa.TASA900')
for key in air.keys():
prop, sep, mod = key.partition('_')
if mod!='std':
print prop,' & ',
print '%2.3f'%tasa[prop+sep+'mean'],' & ','%2.3f'%tasa[prop+sep+'std'],' & ',
print '%2.3f'%air[prop+sep+'mean'],' & ','%2.3f'%air[prop+sep+'std'],'\\\\'
def dataset_stats(dataset):
"""
Print and plot statistics for a given dataset.
A histogram is plotted with the document length distribution of the data.
"""
print '> Reading data..', dataset
corpus_path = '../data/'+dataset
(documents, labels) = data.read_files(corpus_path)
file_names = data.get_file_names(corpus_path)
lengths = []
empty = 0
for i,d in enumerate(documents):
d = preprocess.tokenize_tokens(d)
lengths.append(len(d))
if len(d)==0:
print file_names[i],'is empty'
empty += 1
lengths = numpy.array(lengths)
print '# documents:',len(documents)
print '# empty documents:',empty
print '# words:',sum(lengths)
print 'length avg:',lengths.mean()
print 'length stddev:',lengths.std()
print
print 'document lengths (sorted):',sorted(lengths)
plotter.histogram(lengths,'# tokens','# documents','',bins=80)
def solution_similarity_stats(dataset='air/solutions_preprocessed'):
"""
Plots histogram of solution-solution similarity distribution of a dataset.
"""
print '> Reading data..', dataset
corpus_path = '../data/'+dataset
(documents, labels) = data.read_files(corpus_path)
print '> Creating vector representations..'
vectors = freq_representation.text_to_vector(documents, freq_representation.FrequencyMetrics.TF_IDF)
print '> Calculating similarities..'
distances = scipy.spatial.distance.cdist(vectors.T, vectors.T, 'cosine')
diag = numpy.diag([2.0]*len(distances),0) # move similarities of "self" to -1
distances = distances + diag
similarities = 1.0 - distances
similarities = similarities.ravel()
similarities = [s for s in similarities if s >= 0]
print plotter.histogram(similarities,'similarity','# matches','',bins=150)
print
print max(similarities)
print min(similarities)
print float(sum(similarities))/len(similarities)
num = len([sim for sim in similarities if sim < 0.23])
print 'fraction sims < .23:', float(num)/len(similarities)
def test_document_lengths(dataset='mir'):
print '> Reading data..', dataset
path = '../data/'+dataset+'/problem_descriptions_preprocessed'
docs, _ = data.read_files(path)
names = data.get_file_names(path)
print "PROBLEM DESCRIPTIONS"
for i, d in enumerate(docs):
if not d:
print names[i], "is empty"
path = '../data/'+dataset+'/solutions_preprocessed'
docs, _ = data.read_files(path)
names = data.get_file_names(path)
print "SOLUTIONS"
for i, d in enumerate(docs):
if not d:
print names[i], "is empty"
def term_centrality_study(doc='air/reports_text/2005/a05a0059.html', num=20):
def _print_terms(cents, rep, num):
ts = _top_cents(cents, num)
terms = []
for t in ts:
terms.append(t[0])
print rep + ' & ' + ', '.join(terms) + ' \\\\'
def _top_cents(cents,num):
return sorted(cents.iteritems(), key = operator.itemgetter(1), reverse = True)[0:num]
def _calc_cents(g, metric, gcents=None):
if gcents: icc = graph_representation.calculate_icc_dict(gcents)
else: icc = None
return graph_representation.graph_to_dict(g, metric, icc)
import operator
import dependency_experiments
import co_occurrence_experiments
dataset = 'air/reports'
path = '../data/'+doc
doc = data.read_file(path)
metric = graph.GraphMetrics.DEGREE
context = 'window'
g = graph_representation.construct_cooccurrence_network(doc, context=context)
cents = _calc_cents(g, metric)
_print_terms(cents, 'Co-occurrence TC', num)
gcents = co_occurrence_experiments.retrieve_centralities(dataset, context, metric)
cents = _calc_cents(g, metric, gcents)
_print_terms(cents, 'Co-occurrence TC-ICC', num)
metric = graph.GraphMetrics.EIGENVECTOR
deps = data._text_to_dependencies(doc)
g = graph_representation.construct_dependency_network(deps)
cents = _calc_cents(g, metric)
_print_terms(cents, 'Dependency TC', num)
gcents = dependency_experiments.retrieve_centralities(dataset, metric)
cents = _calc_cents(g, metric, gcents)
_print_terms(cents, 'Dependency TC-ICC', num)
fdict = freq_representation.text_to_dict([doc], freq_representation.FrequencyMetrics.TF_IDF)[0]
_print_terms(fdict, 'TF-IDF', num)
fdict = freq_representation.text_to_dict([doc], freq_representation.FrequencyMetrics.TF)[0]
_print_terms(fdict, 'TF', num)
def plot_centrality_evaluations():
import data
labels = ['~~~~~Degree','Closeness','Current-flow closeness','Betweenness','Current-flow betweenness','Load','Eigenvector','PageRank','HITS Authorities','HITS Hubs']
d = [
[0.5694444444444444,0.5333333333333333],#[0.5555555555555556,0.5333333333333333],
[0.525,0.5166666666666667],
[0.5194444444444445,0.5111111111111111],
[0.4361111111111111,0.43333333333333335],
[0.42777777777777776,0.4187],#[0.42777777777777776,0.05],
[0.4361111111111111,0.4222222222222222],
[0.5183333333333333,0.5055555555555555],
[0.5573333333333333,0.5433333333333333],
[0.5083333333333333,0.5083333333333333],
[0.5083333333333333,0.5083333333333333]]
ys = {.3:'0.0',.35:'...',.4:'0.4',.5:'0.5',.6:'0.6',.7:'0.7',.8:'0.8'}
fig = plotter.tikz_barchart(d, None, scale = 3.5, yscale=3, color='black', legend = ['TC','TC-ICC'], legend_sep=0.6, low_cut=0.3, y_tics=ys, tick=False)
data.write_to_file(fig,'../../masteroppgave/paper/parts/tikz_bar_co-occurrence.tex',mode='w')
d = [
[0.52500000000000002,0.5028],
[0.58894242452424244,0.5056],#[0.57499999999999996,0.5056],
[0.56944444444444442,0.5028],
[0.36388888888888887,0.3806],
[0.23333333333333334,0.2263],#[0.23333333333333334,0.05],
[0.35555555555555557,0.3778],
[0.49722222222222223,0.4667],
[0.52777777777777779,0.4833],
[0.49722222222222223,0.4611],
[0.49722222222222223,0.4611]]
ys = {.0:'0.0',.1:'',.2:'0.2',.3:'',.4:'0.4',.5:'',.6:'0.6',.7:'',.8:'0.8'}
fig = plotter.tikz_barchart(d, None, scale = 3.5, yscale=1.6, color='black', y_tics=ys, tick=False)
data.write_to_file(fig,'../../masteroppgave/paper/parts/tikz_bar_dependency.tex',mode='w')
fig = plotter.tikz_barchart(d, labels, scale = 3.5, color='black', labels_only=True)
data.write_to_file(fig,'../../masteroppgave/paper/parts/tikz_bar_labels.tex',mode='w')
def plot_classification_comparison_experiment():
import data
labels = ['Freqency','Co-occurrence','Dependency']
legend = ['local','global']
d = [[0.6693,0.6375],
[0.6880,0.6875],
[0.6827,0.6763]]
ys = {.4:'0.0',.45:'...',.5:'0.5',.6:'0.6',.7:'0.7',.8:'0.8'}
fig = plotter.tikz_barchart(d, labels, scale = 3.5, yscale=3, color='black', legend=legend, legend_sep=0.6, low_cut=0.4, y_tics=ys, tick=False)
data.write_to_file(fig,'../../masteroppgave/report/imgs/tikz/comp_classification.tex',mode='w')
def plot_classification_evaluations_experiment():
import data
labels = ['Freqency','Co-occurrence','Dependency']
legend = ['local','global']
d = [[0.5678,0.5455], # .., -2
[0.5694,0.5333],
[0.5889,0.5056]]
ys = {.3:'0.0',.35:'...',.4:'0.4',.5:'0.5',.6:'0.6',.7:'0.7',.8:'0.8'}
fig = plotter.tikz_barchart(d, labels, scale = 3.5, yscale=3, color='black', legend=legend, legend_sep=0.6, low_cut=0.3, y_tics=ys, tick=False)
data.write_to_file(fig,'../../masteroppgave/report/imgs/tikz/eval_classification.tex',mode='w')
def plot_retrieval_comparison_experiment():
import data
labels = ['Freqency','Co-occurrence','Dependency']
legend = ['local','global']
d = [[0.2243,0.2392],
[0.2205,0.2472],
[0.2094,0.2555]]
ys = {0:'0.0', .1:'0.1', .2:'0.2', .3:'0.3', .4:'0.4'}
fig = plotter.tikz_barchart(d, labels, scale = 3.5, yscale=3, color='black', legend=None, y_tics=ys, tick=False)
data.write_to_file(fig,'../../masteroppgave/report/imgs/tikz/comp_retrieval.tex',mode='w')
def plot_retrieval_evaluations_experiment():
import data
labels = ['Freqency','Co-occurrence','Dependency']
legend = ['local','global']
d = [[0.2240,0.2459],
[0.2227,0.2559],
[0.2020,0.2048]]
ys = {0:'0.0', .1:'0.1', .2:'0.2', .3:'0.3', .4:'0.4'}
fig = plotter.tikz_barchart(d, labels, scale = 3.5, yscale=3, color='black', legend=None, y_tics=ys, tick=False)
data.write_to_file(fig,'../../masteroppgave/report/imgs/tikz/eval_retrieval.tex',mode='w')
if __name__ == "__main__":
#~ do_classification_experiments('tasa/TASA900',[])
#~ do_retrieval_experiments('air/problem_descriptions', 'air/solutions',[])
#~ plot_sentence_lengths('output/tasa_sentence_lengths.pkl')
#~ print_network_props()
#~ dataset_stats('tasa/TASA900_text')
#~ solution_similarity_stats()
#~ plot_centrality_evaluations()
#~ classification_comparison_graph(graph_type='co-occurrence', icc=True)
#~ classification_comparison_graph(graph_type='dependency', icc=True)
#~ classification_comparison_freq()
#~ retrieval_comparison_graph(dataset='mir', graph_type='co-occurrence', use_icc=False)
#~ retrieval_comparison_graph(dataset='mir', graph_type='dependency', use_icc=True)
#~ retrieval_comparison_freq('air')
#~ test_document_lengths()
#~ solution_similarity_stats(dataset='mir/solutions_preprocessed')
#~ solution_similarity_stats()
#~ term_centrality_study()
#~ freq_classification()
plot_centrality_evaluations()
#~ plot_retrieval_comparison_experiment()
#~ plot_classification_comparison_experiment()
#~ plot_retrieval_evaluations_experiment()
#~ plot_classification_evaluations_experiment()