-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMedicalBayesianNetwork.py
More file actions
65 lines (45 loc) · 2.17 KB
/
MedicalBayesianNetwork.py
File metadata and controls
65 lines (45 loc) · 2.17 KB
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
from BayesianNetwork import *
'''
The patient class defines a series of known observations for an individual
name: The patients name, not necessarily unique
evidenceVariables: The variables which have known values
evidenceValues: The value of the corresponding variable
'''
class Patient:
def __init__(self, name, evidenceVars, evidenceVals):
self.name = name
self.evidenceVars = evidenceVars
self.evidenceVals = evidenceVals
def evidenceVariables(self):
'''return a list of the evidence variables that can be modified'''
return list(self.evidenceVars)
def evidenceValues(self):
'''return a list of the evidence values that can be modified'''
return list(self.evidenceVals)
'''
The MedicalBayesianNetwork represents a Bayesian network with some variables
having special status:
BayesNet : the underlying Bayesian Network (A BayesianNetwork object)
treatmentVars : a list of variables in Bayesnet representing possible treatments
outcomeVars: a list of variables in Bayesnet representing possible patient
outcomes
Note that the treatment and outcome variables must be variables of the Bayes net
Treament and Outcome variables should be mutually exclusive
'''
class MedicalBayesianNetwork:
def __init__(self, BayesNet, treatmentVars, outcomeVars):
self.name = BayesNet.name
self.net = BayesNet
self.treatmentVars = treatmentVars
self.outcomeVars = outcomeVars
def set_evidence_by_patient(self, patient):
'''Sets the evidence variables in the associated Bayes net to match
the evidence displayed by the patient'''
for i in range(0,len(patient.evidenceVars)):
patient.evidenceVars[i].set_evidence(patient.evidenceVals[i])
def getTreatmentVars(self):
'''return a list of the treatment variables that can be modified'''
return list(self.treatmentVars)
def getOutcomeVars(self):
'''return a list of the outcome variables that can be modified'''
return list(self.outcomeVars)