-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtester.py
62 lines (51 loc) · 2.24 KB
/
tester.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
import random
class Tester:
def __init__(self, learn): #Initialization
self.space = learn.space
self.trajectories = learn.trajectories
self.patient = learn.patient
self.healthy = learn.health
self.newHealthy = []
self.newPatient = []
self.people = []
self.unknown = learn.unknown
self.hygiene = learn.hygiene
self.timeSetter = learn.timeSetter
self.socialDis = 0.1
self.otherParameters = 0.1
self.test()
def test(self): #THE PREDICTOR SYSTEM FOR FINDING THE POSSIBILITY OF GETTING THE DISEASE FOR EACH PERSON
self.people = self.unknown
self.numberOfTest = len(self.people)
for index in range(self.numberOfTest):
person = random.choice(self.people)
t = 0
day = 0
p = 1
totalSP = 1
for place in self.trajectories[person]:
if t == self.timeSetter:
totalSP *= p #probability of being healthy until today
totalP = 1-totalSP
day += 1
t = 0
p = 1
if day == 4:
break
else:
temp = self.PPPD(person, day, place, t) #probability of getting patient in a place in a day
p *= (1-temp) #probability of being health in a day until now
t += 1
if totalP < 0.5:
self.newHealthy.append(person)
else:
self.newPatient.append(person)
print("person", person)
print("hygiene:", self.hygiene[person])
print("probability of patient:", totalP, "\n")
if self.people == self.healthy:
print("accuracy:", len(self.newHealthy)/len(self.healthy))
elif self.people == self.patient:
print("accuracy:", len(self.newPatient)/len(self.patient))
def PPPD(self, traj, day, place, t): #probability of patient in a place in a day
return (1-self.hygiene[traj])*self.space[day][t][place]*self.socialDis*self.otherParameters