forked from PhPeKe/OB1_SAM
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main_exp.py
76 lines (62 loc) · 2.34 KB
/
main_exp.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
# -*- coding: utf-8 -*-
# 1-10-2020 Noor Seijdel
# In this file, "simulate_experiments" is called and the results are stored
from reading_simulation import reading_simulation
from simulate_experiments import simulate_experiments
#from simulate_experiments_activationfreqpred import simulate_experiments
from analyse_data_pandas import get_results
import multiprocessing as mp
import pickle
import cProfile
import pstats
from analyse_data_pandas import get_results, get_results_simulation
import pickle
import scipy
import time
import numpy as np
from get_scores import get_scores
import parameters_exp as pm
import pandas as pd
from get_parameters import get_params
# Get parameters for tuning
parameters, bounds, names = get_params(pm)
# Init distance variables for the reading function used in tuning
OLD_DISTANCE = np.inf
N_RUNS = 0
output_file_all_data, output_file_unrecognized_words = ("Results/all_data"+pm.language+".pkl","Results/unrecognized"+pm.language+".pkl")
start_time = time.time()
tasks = ["Flanker", "Sentence"]
for task in tasks:
if task == "Flanker":
pm.use_flanker_task = True
pm.use_sentence_task = False
elif task == "Sentence":
pm.use_sentence_task = True
pm.use_flanker_task = False
if pm.run_exp:
# Run the reading model
#(lexicon, all_data, unrecognized_words) = simulate_experiments(parameters=[])
(lexicon, all_data, unrecognized_words) = simulate_experiments(parameters=[])
# Save results: all_data...
all_data_file = open(output_file_all_data,"wb")
pickle.dump(all_data, all_data_file)
all_data_file.close()
# ...and unrecognized words
unrecognized_file = open(output_file_unrecognized_words, "wb")
pickle.dump(unrecognized_words, unrecognized_file)
unrecognized_file.close()
with open("unrecognized.txt", "w") as f:
f.write("Total unrecognized: " + str(len(unrecognized_words)))
f.write("\n")
for uword in unrecognized_words:
f.write(uword)
f.write("\n")
with open("alldata.txt", "w") as f:
f.write("\n")
for uword in all_data:
f.write(str(uword))
f.write("\n")
if pm.analyze_results:
get_results_simulation(output_file_all_data,output_file_unrecognized_words)
time_elapsed = time.time()-start_time
print("Time elapsed: "+str(time_elapsed))