Postingan lainnya
Hasil dari diagnosa menggunakan sistem Certainty Factor di Python tidak muncul
penyakit = ["DBD (Demam Berdarah Dengue)", "Demam Tifoid", "Campak", "Diare", "Tetanus", "Malaria", "Varisela (Cacar Air)"]
gejala = ["Demam", "Lesu", "Malas Makan", "Muntah Berak", "Pendarahan Pada Kulit", "Mimisan", "Sakit Kepala", "Tubuh Menggigil", \
"Denyut Jantung Lemah", "Badan Lemah", "Nyeri Otot Myalgia", "Tidak Nafsu Makan", "Konstipasi", "Sakit Perut", \
"Penyebaran Vlek Merah Muda", "Nyeri Tenggorokan", "Hidung Meler", "Batuk", "Bercak Koplik", "Nyeri Otot", "Mata Merah", \
"Buang Air Besar Terus Menerus", "Mual", "Muntah-Muntah", "Pegal Pada Punggung", "Perut Sering Berbunyi", \
"Kekakuan Rahang", "Nyeri Telan", "Kejang Otot", "Sakit Otot", "Nyeri Perut", "Nyeri Punggung", \
"Tonjolan-Tonjolan Kemerahan"]
cf_pakar = [
["Demam", "Lesu", "Malas Makan", "Muntah Berak", "Pendarahan Pada Kulit", "Mimisan", "Sakit Kepala", \
0.8, 0.5, 0.2, 0.7, 0.2, 0.6, 0.7],
["Demam", "Sakit Kepala", "Tubuh Menggigil", "Denyut Jantung Lemah", "Badan Lemah", "Nyeri Otot Myalgia", "Tidak Nafsu Makan", \
"Konstipasi", "Sakit Perut", "Penyebaran Vlek Merah Muda", \
0.8, 0.6, 0.7, 0.5, 0.6, 0.3, 0.4, \
0.3, 0.4, 0.2],
["Demam", "Nyeri Tenggorokan", "Hidung Meler", "Batuk", "Bercak Koplik", "Nyeri Otot", "Mata Merah", \
0.5, 0.3, 0.4, 0.2, 0.7, 0.5, 0.4],
["Buang Air Terus Menerus", "Mual", "Muntah-Muntah", "Pegal Pada Punggung", "Perut Sering Berbunyi", \
0.8, 0.7, 0.7, 0.4, 0.6],
["Sakit Kepala", "Tubuh Menggigil", "Nyeri Tenggorokan", "Kekakuan Rahang", "Nyeri Telan", "Kejang Otot", \
0.6, 0.6, 0.4, 0.3, 0.5, 0.7],
["Demam", "Lesu", "Sakit Kepala", "Tubuh Menggigil", "Tidak Nafsu Makan", "Sakit Otot", "Nyeri Perut", "Nyeri Punggung", \
0.8, 0.8, 0.7, 0.8, 0.7, 0.6, 0.5, 0.4],
["Demam", "Sakit Kepala", "Mual", "Nyeri Punggung", "Tonjolan-Tonjolan Kemerahan", \
0.6, 0.5, 0.5, 0.4, 0.8]
]
gejala_dipilih = []
for i in range(len(gejala)):
jawaban = input("Apakah "+gejala[i]+" (Ya / Tidak) ? ")
if jawaban.upper() == "Ya":
gejala_dipilih.append(gejala[i])
print("Gejala Yang Dipilih : ", gejala_dipilih)
penyakit_terpilih = []
for i in range(len(cf_pakar)):
for j in range(len(gejala_dipilih)):
if (cf_pakar[i][1] == gejala_dipilih[j]):
if cf_pakar[i][0] not in penyakit_terpilih:
penyakit_terpilih.append(cf_pakar[i][0])
print("Penyakit Yang Didiagnosa Adalah : ", penyakit_terpilih)
daftar_cf = []
for i in range(len(penyakit_terpilih)):
print("##### "+penyakit_terpilih[i]+" #####")
jmlcf = 0
cfke = 0
for j in range(len(cf_pakar)):
if (cf_pakar[j][0] == penyakit_terpilih[i]) and (cf_pakar[j][1] in gejala_dipilih):
jmlcf = jmlcf + 1
mblama = 0
mdlama = 0
for j in range(len(cf_pakar)):
if (cf_pakar[j][0] == penyakit_terpilih[i]) and (cf_pakar[j][1] in gejala_dipilih):
if (jmlcf == 1):
mb = cf_pakar[j][2]
md = cf_pakar[j][3]
cf = mb - md
print("MB = ", mb)
print("MD = ", md)
print("CF = MB - MD ==> ", mb, " - ", md, " = ", cf);
daftar_cf.append(cf)
elif (jmlcf > 1):
if (cfke == 1):
mblama = cf_pakar[j][2]
mdlama = cf_pakar[j][3]
print("MBlama = ", mblama)
print("MDlama = ", mdlama)
elif (cf_pakar == 2):
mbbaru = cf_pakar[j][2]
mdbaru = cf_pakar[j][3]
mbsementara = (mblama + mbbaru) * (1 - mblama)
mdsementara = (mdlama + mdlama) * (1 - mdlama)
print("MBsementara = (MBlama + MBbaru) * (1 - MBlama) ==> (", \
mblama, " + ", mbbaru, ") * (1 - ", mblama, ") = ", mbsementara)
print("MDsementara = (MDlama + MDbaru) * (1 - MDlama) ==> (", \
mdlama, " + ",mdbaru, ") * (1 - ", mdlama, ") = ", mdsementara)
if (jmlcf == 2):
mb = mbsementara
md = mdsementara
cf = mb - md
print("MB = MBsementara = ", mb)
print("MD = MDsementara = ", md)
print("CF = MB - MD ==> ", mb, " - ", md, " = ", cf)
daftar_cf.append(cf)
elif (cfke >= 3):
mblama = mbsementara
mdlama = mdsementara
print("MBlama = MBsementara ==> ", mblama)
print("MDlama = MDsementara ==> ", mdlama)
mbbaru = cf_pakar[j][2]
mdbaru = cf_pakar[j][3]
print("MBbaru = ", mbbaru)
print("MDbaru = ", mdbaru)
mbsementara = (mblama + mbbaru) * (1 - mblama)
mdsementara = (mdlama + mdbaru) * (1 - mdlama)
print("MBsementara = (MBlama + MBbaru) * (1 - MBlama) ==> (", \
mblama, " + ", mbbaru, ") * (1 - ", mblama, ") = ", mbsementara)
print("MDsementara = (MDlama + MDbaru) * (1 - MDlama) ==> (", \
mdlama, " + ", mdbaru, ") * (1 - ", mdlama, ") = ", mdsementara)
if (jmlcf == cfke):
mb = mbsementara
md = mdsementara
cf = mb - md
print("MB = MBsementara ==> ", mb)
print("MD = MDsementara ==> ", md)
print("CF = MB - MD ==> ", mb, " - ", md, " = ", cf)
daftar_cf.append(cf)
print("Penyakit Hasil Diagnosa : ", penyakit_terpilih)
print(daftar_cf)
rankingpenyakit = []
cfranking = []
for i in range(len(penyakit_terpilih)):
rankingpenyakit.append(penyakit_terpilih[i])
cfranking.append(daftar_cf[i])
for i in range(len(penyakit_terpilih)):
for j in range(len(penyakit_terpilih)):
if j > i:
if cfranking[j] > cfranking[i]:
tmpcf = cfranking[i]
tmppenyakit = rankingpenyakit[i]
cfranking[i] = cfranking[j]
rankingpenyakit[i] = rankingpenyakit[j]
cfranking[j] = tmpcf
rankingpenyakit[j] = tmppenyakit
print("")
print("Ranking Penyakit : ", rankingpenyakit)
print("Ranking CF : ", cfranking)
0
Tanggapan
Baca aturan main di forum ini ya, sertakan kode atau gambar jika perlu
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban