/
AI_research_police.py
173 lines (154 loc) · 5.08 KB
/
AI_research_police.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
import getpass
import pyttsx3
import playsound
from modules.simulations.statistical_power import p_value_sonata
from modules.simulations.statistical_power import simulate_experiments
from modules.simulations.statistical_power import simulate_correlations
from modules.simulations.statistical_power import simulate_file_drawer
class __DefaultSentences:
'''
Doctring here
'''
def __init__(self):
self.greetings = 'Greetings human, I am your friendly neighborhood' \
' robot research assistant'
self.time_to_research = 'Time to do some research!'
self.job_done = 'Job done, impeccable execution as usual'
self.ready_to_rumble = 'I am ready to rumble'
self.you_are_right = 'That seems right, get yourself a +1 in intellect'
self.you_are_wrong = 'You got it wrong mate, maybe try doing an ' \
'evolutionary leap?'
self.farewell = 'It is time for me to go now, you can go back' \
' to do some mediocre research'
class RobotResearchAssistant(__DefaultSentences):
'''
Doctring here
'''
def __init__(self, mute=False):
'''
'''
self.cosmic_password = getpass.getpass(
'Initialize with cosmic password '
)
super(RobotResearchAssistant, self).__init__()
self.brain = {
'play p value sonata': p_value_sonata,
'simulate experiments': simulate_experiments,
'simulate correlations': simulate_correlations,
'simulate filedrawer': simulate_file_drawer,
}
self.vocal_apparatus = pyttsx3.init()
self.mute = mute
self.speak(
sentences=[self.greetings]
)
def __del__(self):
'''
Docstring here
'''
self.speak(
sentences=[self.farewell]
)
def __unlock_cosmic_powers(self, cosmic_password):
'''
Doctring here
'''
if cosmic_password != self.cosmic_password:
self.speak(
sentences=[self.you_are_wrong]
)
return False
else:
self.speak(
sentences=[self.you_are_right,
'I am initializing my deep, deep, deep, deeeeeep'
' neural network',
'titutitututu',
'tutituti',
'titi',
'tu'
]
)
if not self.mute:
playsound.playsound('sounds\\pcp.mp3')
self.speak(
sentences=[self.ready_to_rumble,
self.time_to_research
]
)
return True
def speak(self, sentences):
'''
Doctring here
'''
for sentence in sentences:
self.vocal_apparatus.say(sentence)
if not self.mute:
self.vocal_apparatus.runAndWait()
def do_experiment(self, experiment_function, **kwargs):
'''
Doctring here
'''
self.speak(
sentences=['I am going to {}'.format(experiment_function)]
)
self.brain[experiment_function](**kwargs)
def do_research(self, expriments_parameters):
'''
Doctring here
'''
self.speak(
sentences=['Please, unlock my artificially intelligent brain ']
)
unlocked = False
while not unlocked:
cosmic_password = getpass.getpass('Cosmic password: ')
unlocked = self.__unlock_cosmic_powers(cosmic_password)
for function, parameters in expriments_parameters.items():
input('Next')
self.do_experiment(
experiment_function=function,
**parameters
)
if parameters['verbose']:
self.speak(
sentences=[self.job_done]
)
if __name__ == '__main__':
experiments_parameters = {
'play p value sonata': {
'sample_size': 30,
'effect_size': 0.4,
'n_experiments': 8,
'alpha': 0.05,
'sounds_path': 'sounds',
'verbose': True
},
'simulate experiments': {
'sample_sizes': [5, 10, 20, 40, 80, 160, 320],
'effect_size': 0.4,
'n_experiments': 100,
'alpha': 0.05,
'viz_path': 'figures',
'verbose': False
},
'simulate correlations': {
'correlations': [0.05, 0.2, 0.6],
'sample_0': 20,
'sample_1': 2000,
'viz_path': 'figures',
'verbose': False
},
'simulate filedrawer': {
'sample_size': 30,
'effect_size_mu': 0.3,
'effect_size_sigma': 0.1,
'n_experiments': 1000,
'alpha': 0.05,
'viz_path': 'figures',
'verbose': False
}
}
rra = RobotResearchAssistant(mute=False)
rra.do_research(expriments_parameters=experiments_parameters)
del rra