-
Notifications
You must be signed in to change notification settings - Fork 0
/
General.py
187 lines (161 loc) · 8.21 KB
/
General.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
import time
import numpy as np
import os
import winsound
def experimentVariables(projectName):
'''
This function returns all the variables necessary to start a experiment including:
name of the experiment
datasets locations
variables to report from the experiment
what to report from the experiment
'''
computerName=os.environ.get('COMPUTERNAME')
if projectName== 'unlabeledModelS':
if computerName=='JULIAN':
from sklearn.datasets import load_boston, load_iris, load_diabetes, load_digits, load_linnerud
datasets={'boston':load_boston(),'iris':load_iris(),'diabetes':load_diabetes(),'digits':load_digits(),'linnerud':load_linnerud()}
print('working at JULIAN@CMU')
dataset='digits'
numTests=50
experimentName='One'
agmntlvl=0
description='here the description of this experiment'
data=datasets[dataset]['data']
labels=datasets[dataset]['target']
verbose=0
plots=False
signal2plot='f1_score_mv_predval_agmnt'
# signal2plot='f1_score_val_predval_agmnt'
#The next are variables that store the outcomes from the
#experiment
variables=\
'spear=[]\n'
return {'dataset':dataset,'numTests':numTests,'experimentName':experimentName,\
'description':description,'agmntlvl':agmntlvl,'variables':variables,'data':data,\
'labels':labels,'verbose':verbose,'plots':plots,'signal2plot':signal2plot}
else:
print('Variables not defined for Julian@Laptop')
def projectPaths(projectName):
'''
This function returns the paths necesary to work on several
projects. The paths change according to the machine this function
is called from.
'''
A=os.environ.get('COMPUTERNAME')
if projectName == 'problematic_use':
if A=='JULIAN':
print('working on JULIAN@CMU')
main_path='K:/research_data_sets/kettle/problematic_use_data/problematic_use_data'
data_path='K:/research_data_sets/kettle/problematic_use_data/problematic_use_data/SOFDataSet'
results_path='K:/research_data_sets/kettle/problematic_use_data/problematic_use_data/Results'
transitions_path='K:/research_data_sets/kettle/problematic_use_data/problematic_use_data/transitionsData'
os.chdir(data_path);
else :
print('working on Julian@laptop')
main_path='E:/research_data_sets/kettle/problematic_use_data/problematic_use_data'
data_path='E:/research_data_sets/kettle/problematic_use_data/problematic_use_data/SOFDataSet'
results_path='E:/research_data_sets/kettle/problematic_use_data/problematic_use_data/Results'
transitions_path='E:/research_data_sets/kettle/problematic_use_data/problematic_use_data/transitionsData'
os.chdir(data_path);
return {'main_path':main_path,'data_path':data_path,'results_path':results_path,'transitions_path':transitions_path}
if projectName == 'Activity_RS':
if A=='JULIAN':
print('working on JULIAN@CMU')
main_path='F:/Activity_RS/Dataset'
data_path='F:/Activity_RS/Dataset'
results_path='F:/Activity_RS/Results'
print('Moved to the data path '+data_path)
os.chdir(data_path);
else :
print('working on Julian@laptop')
main_path='G:/Activity_RS/Dataset'
data_path='G:/Activity_RS/Dataset'
results_path='G:/Activity_RS/Results'
print('Moved to the data path '+data_path)
os.chdir(data_path);
return {'main_path':main_path,'data_path':data_path,'results_path':results_path}
if projectName == 'Discovering_APPC':
if A=='JULIAN':
print('working on JULIAN@CMU')
print('This paths have not being defined yet')
main_path='F:/Activity_RS/Dataset'
data_path='F:/Activity_RS/Dataset'
results_path='F:/Activity_RS/Results'
print('Moved to the data path '+data_path)
os.chdir(data_path);
else :
print('working on Julian@laptop')
main_path='E:/research_data_sets/neill/upmc'
data_path='E:/research_data_sets/neill/upmc/DeIDOutput/copd_pat_10'
results_path='E:/research_data_sets/neill/upmc/unifiedFiles/'
print('Moved to the data path '+data_path)
os.chdir(data_path);
return {'main_path':main_path,'data_path':data_path,'results_path':results_path}
if projectName == 'EigenRoutines':
if A=='JULIAN':
print('working on JULIAN@CMU')
main_path='K:/research_data_sets/kettle/problematic_use_data/problematic_use_data'
data_path='K:/research_data_sets/kettle/problematic_use_data/problematic_use_data/ScreenOff-DataSet'
results_path='K:/research_data_sets/kettle/problematic_use_data/problematic_use_data/Results'
transitions_path='K:/research_data_sets/kettle/problematic_use_data/problematic_use_data/transitionsData'
os.chdir(data_path);
else :
print('working on Julian@laptop')
main_path='E:/research_data_sets/kettle/problematic_use_data/problematic_use_data'
data_path='E:/research_data_sets/kettle/problematic_use_data/problematic_use_data/ScreenOff-DataSet'
results_path='E:/research_data_sets/kettle/problematic_use_data/problematic_use_data/Results'
transitions_path='E:/research_data_sets/kettle/problematic_use_data/problematic_use_data/transitionsData'
os.chdir(data_path);
return {'main_path':main_path,'data_path':data_path,'results_path':results_path,'transitions_path':transitions_path}
if projectName == 'topicModels':
if A=='JULIAN':
print('working on JULIAN@CMU')
main_path='K:/research_folders/topicModels/'
data_path='--not provided yet--'
results_path='K:/research_folders/topicModels/results/'
corpus_path='K:/research_folders/topicModels/corpus/'
# os.chdir(data_path);
else :
print('working on Julian@laptop')
main_path='E:/research_data_sets/kettle/problematic_use_data/problematic_use_data'
data_path='E:/research_data_sets/kettle/problematic_use_data/problematic_use_data/ScreenOff-DataSet'
results_path='E:/research_data_sets/kettle/problematic_use_data/problematic_use_data/Results'
transitions_path='E:/research_data_sets/kettle/problematic_use_data/problematic_use_data/transitionsData'
# os.chdir(data_path);
return {'main_path':main_path,'data_path':data_path,'results_path':results_path,'corpus_path':corpus_path}
if projectName== 'unlabelebeledModelS':
if A=='JULIAN':
print('working at JULIAN@CMU')
else:
print('Variables not defined for Julian@Laptop')
def transitionsExtractor(data,timeData):
last=data[0]
dataOut=[]
timeOut=[]
dataOut.append(data[0])
timeOut.append(timeData[0])
for i in range(len(data)):
if last!=data[i]:
dataOut.append(data[i])
timeOut.append(timeData[i])
last=data[i]
return {'dataOut':dataOut,'timeOut':timeOut}
## Miscellaneous functions
def tic(vars=0):
'''
This function works similarly to tic in matlab. When called tic(0) internally stores the current time
when called as tic(1) returns the time elapsed between the last tic(0) and tic(1)
Calling tic(0) always overwrites the starting time
'''
if vars==1:
t=time.time()-tic.start
else:
tic.start=time.time()
t=tic.start
return t
import winsound
def beep():
Freq = 3000 # Set Frequency To 2500 Hertz
Dur = 1000 # Set Duration To 1000 ms == 1 second
winsound.Beep(Freq,Dur)