-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrsh.py
28 lines (24 loc) · 825 Bytes
/
trsh.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
import pandas as pd
import numpy as np
def main():
symptoms = pd.read_csv("symptom.csv", delimiter=";")
patient_symptoms = np.random.randint(0, 2, symptoms.shape[0])
print(patient_symptoms)
diseases = pd.read_csv("disease.csv", delimiter=";")
prob_diseases = []
for i in range(diseases.shape[0] - 1):
prob_diseases.append(diseases.iloc[i][-1] / diseases.iloc[-1][-1])
prob_max = 0
index_max = -1
for i in range(len(prob_diseases)):
prob = 1
for j in range(len(patient_symptoms)):
if patient_symptoms[j] == 1:
prob *= symptoms.iloc[j][i + 1]
prob *= prob_diseases[i]
if prob > prob_max:
prob_max = prob
index_max = i
print(diseases.iloc[index_max][0])
if __name__ == '__main__':
main()