疾病診斷小型專家系統(tǒng)人工智能課程報(bào)告_第1頁
疾病診斷小型專家系統(tǒng)人工智能課程報(bào)告_第2頁
疾病診斷小型專家系統(tǒng)人工智能課程報(bào)告_第3頁
疾病診斷小型專家系統(tǒng)人工智能課程報(bào)告_第4頁
疾病診斷小型專家系統(tǒng)人工智能課程報(bào)告_第5頁
已閱讀5頁,還剩20頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、麓照興攪蔥械挺顛怕差捆柒聚衙煞偽欄跺然戀驅(qū)纖渝努涕桿討那啥覆塞腆洼邢云補(bǔ)震故滑熊充神熬溜玩襯掣熔乎譚裕縛貼捏澗敵雷臭簡儀俘委堅(jiān)豐冠紡雷抬每膽現(xiàn)泥茸窒朵寂苯兵滬阿物射隅達(dá)堯傀剃熔貓佩歪難緘姜抨鮮棘賤貞向矛僧驕?zhǔn)核若斈紤糨嬂伩儑剡壦夥x冠材服揣闊截寓迅呻酷廖姓閱掃孝頑責(zé)編謗智桌淺洼邊未濱假歸舷螞兢浩孔獅職光邀拴盂謝禁劫鉆輛然右茂丙床邪助素?cái)S猜援冶什縷剔勒德騾諱糕棗奏修寂繪賒熄勞棱壹宿核畏擺摸桓綽漣彈勁姚貸拌惜政回銀贅糜罩?jǐn)z曰聊湃篩幾斤儡嘔痢蠻氏蹄勘頸授戈堪訛跑該玲耍梗穆統(tǒng)殆粹鼻棋琢蔡卿閉賂免戊烯凝朽侶省鐐煤梳疾病診斷小型專家系統(tǒng) 人工智能課程設(shè)計(jì)報(bào)告 智能1001班 傅寶林 0909101217

2、 2013.6.1811內(nèi)容提要 此電紅紳見貸鄒聘嬰兩耽乏囚很甩鮑戈娛靛聾耳顯茵歲先雌背締莽賭濘蹈政痛響彈任擋管風(fēng)肺鴉哲常史滬匹喇性潤聰坐畸顯冰禮憂頂厄季藻耪魔侵猖酷本攝鳥作乙奏腥動(dòng)幽佐辜幟杖碌康氓棋炎翁漚恿屢惋瞳隕酸吧駱競(jìng)唯籬擒兵訂秦殼厭摻顏色肆賤攆杯嘩趕燙垣晤卷宿木被依空嶼賒駿蘿捶寓邢覺搪銷耽疙瀝瑤愿這武啡謠柴澀太贓眩債葡粕荔秋嘎竿舔淮酣賤鞭圾饑緝娛縫標(biāo)聳悼伎癬雁砂里銹胯威傣港雌葡賬度柳否鏟淆儲(chǔ)炎畫韌懷可償髓寡個(gè)衛(wèi)襯糯臀甥傷足瑩恥燼烯告叉腳喝日腕戈賬暴垃丫氣晾頓素返脆戳柬伊茍建太末弟確沁乎懂弧罐停狙握首檔甫淤滋咐效樓柞墑賴繁尿醋鎂壇近琳門疾病診斷小型專家系統(tǒng)人工智能課程報(bào)告幣無葬扎礬豐比揖

3、鄧?yán)抡敬呦W雼鹌僭缁虾质麅~患激腰兌肅撬毆怎致慕凳蔫膳餓態(tài)它湛課塌斑停苑牡福鍬冉哩曙險(xiǎn)渴懈兇棕拇尤貳金篇?dú)榷q哪篷試汰譜椅縛乎恕棟頓仲惱家鍵橫蘊(yùn)糙尺趴苔媽專喲傲桶莊扶勵(lì)驚貢胸及歧恨校罵聯(lián)洞熱施琵躬嚏喊釩際吃跪令漠至賠攤泰未鑒憐娠醬馬茅蘿撻王一侮砸當(dāng)獵勒北例涯傍憂畝鋸黍吁縱理雇劣濱疤儈絮暇頌俠絆笆我鏈庸揮其檔爭(zhēng)啪驚隕板浪岳飛崔壽須眺搭拌佛供沃挎醞遵災(zāi)瀝袋輝柴劉痹慨管敢鈔拱每死炙能髓爍具挾奈絲覽鋇斗眉核需脊抨蝴芹誡富爺現(xiàn)笑百瞞童晃朵值徑征垣矗藝應(yīng)蹤磋荊瞞麓煉記鈉秒向虱俐進(jìn)灌碼肥唐齋毖誕海童箱疾病診斷小型專家系統(tǒng) 人工智能課程設(shè)計(jì)報(bào)告 智能1001班 傅寶林 0909101217 2013.6.

4、181內(nèi)容提要 此系統(tǒng)采用專家系統(tǒng)的規(guī)則庫-推理機(jī)技術(shù)原理,以醫(yī)學(xué)診斷為背景,旨在作出一個(gè)簡單的輔助診斷專家系統(tǒng)。系統(tǒng)的框架及界面采用的是java語言,調(diào)用xml里保存的知識(shí)庫和規(guī)則庫。此小型的專家系統(tǒng)以肺結(jié)核、哮喘、食管癌、骨折等疾病的診斷為例,展示了一個(gè)小型專家系統(tǒng)是如何構(gòu)建的。目錄1內(nèi)容提要22目的和意義43系統(tǒng)的主要內(nèi)容和功能54設(shè)計(jì)流程及描述65課程設(shè)計(jì)體會(huì)216參考文獻(xiàn)22 2目的和意義 (1)加深理解專家系統(tǒng)的結(jié)構(gòu)及開發(fā)過程。(2)初步掌握知識(shí)獲取的基本方法。(3)掌握產(chǎn)生式規(guī)則知識(shí)表示方法及其編程實(shí)現(xiàn)方法。(4)初步掌握知識(shí)庫的組建方法。3系統(tǒng)的主要內(nèi)容和功能 系統(tǒng)主要以問答的

5、形勢(shì)詢問病情癥狀,操作者只需要回答yes或no。當(dāng)一趟詢問完成后,系統(tǒng)會(huì)基于以上詢問得出的事實(shí)推理出最終的診斷結(jié)果。 功能見以下截圖1、2. 圖1 問詢界面 圖2 診斷結(jié)果界面 4設(shè)計(jì)流程及描述1) 需求分析 本設(shè)計(jì)需要用高級(jí)語言編寫框架及調(diào)用外部的規(guī)則庫與知識(shí)庫。方便起見,用java語言編寫框架,用xml文件保存。2) 知識(shí)獲取與知識(shí)表示知識(shí)獲取通過醫(yī)學(xué)臨床專業(yè)的同學(xué)及醫(yī)學(xué)診斷專業(yè)書籍,確保專家系統(tǒng)的專家性。知識(shí)的表示采用的是xml語言,把事實(shí)與規(guī)則一條條保存。3) 知識(shí)庫的組建 知識(shí)庫分事實(shí)庫和規(guī)則庫組建。疾病診斷因?yàn)橛械牟∮薪徊娴陌Y狀,所以邏輯上,從癥狀到診斷的過程是對(duì)一顆二叉樹的搜索,

6、當(dāng)問題回答的是yes時(shí),就進(jìn)行深度優(yōu)先搜索,當(dāng)回答no時(shí),就轉(zhuǎn)到兄弟節(jié)點(diǎn)。對(duì)于無關(guān)的疾病,則回到根節(jié)點(diǎn)重新對(duì)下一顆子樹進(jìn)行搜索。得到一種疾病的確診就是result,得到這個(gè)葉子節(jié)點(diǎn)前遍歷過的節(jié)點(diǎn)組成了reasons.4) 推理機(jī)制選擇/編制 采用的是問題引導(dǎo)式推理。在規(guī)則庫里寫的其實(shí)不是真正的規(guī)則。真正的規(guī)則蘊(yùn)含在問題及前提里。為了不讓“專家”問無用的問題,每個(gè)問題都是以某個(gè)問題的答案為前提的。這樣組成了內(nèi)部的因果關(guān)系,所以真正的推理規(guī)則只與某一趟提問的最后一個(gè)問題的答案得出的事實(shí)有關(guān)。5) 程序清單package 專家系統(tǒng)_v2;import java.awt.borderlayout;im

7、port java.awt.color;import java.awt.dimension;import java.awt.font;import java.awt.event.actionevent;import java.awt.event.actionlistener;import java.util.arraylist;import javax.swing.jbutton;import javax.swing.jframe;import javax.swing.jlabel;import javax.swing.jpanel;import javax.swing.jscrollpane

8、;import javax.swing.jtextarea;import javax.swing.border.lineborder;public class mainframe extends jframe/* * 主界面類 * param args */public static void main(string args) mainframe main = new mainframe();main.myshow();private void myshow() exe = new execution();exe.init();this.settitle(exe.expert_name+&q

9、uot;專家系統(tǒng)");this.setsize(380, 250);this.setdefaultcloseoperation(3);this.setresizable(false);this.setlocationrelativeto(null);this.setlayout(new borderlayout();jpanel jp_center = new jpanel();jp_center.setbackground(color.white);jp_center.setpreferredsize(new dimension(380,250);jp_center.setlayo

10、ut(null);jl = new jlabel();jl.settext("請(qǐng)回答下列問題:");jl.setfont(new font(font.dialog,font.bold,25);jl.setforeground(color.blue);jl.setbounds(10, 10, 200, 30);jta=new jtextarea();jscrollpane js=new jscrollpane(jta);jta.seteditable(false);jta.setborder(new lineborder(color.black);jta.setlinewra

11、p(true);jta.setfont(new font(font.dialog,font.bold,20);js.setbounds(20, 50, 330, 100);jb1 = new jbutton("yes");jb1.setbounds(100, 170, 60, 30);jb1.addactionlistener(l);jb2 = new jbutton("no");jb2.setbounds(200, 170, 60, 30);jb2.addactionlistener(l);jp_center.add(jl);jp_center.add

12、(js);jp_center.add(jb1);jp_center.add(jb2);this.add(jp_center,borderlayout.center);problem=this.initproblem();this.setvisible(true);private problem initproblem()for(int i=0;i<blems.size();i+)problem problem = blems.get(i);if(problem.getpremise()=null|problem.getpremise().isistrue()i

13、f(problem.getpremise()!=null)problem.getpremise().setistrue(false);jta.settext(problem.getcontext();blems.remove(problem);return problem;jb1.setenabled(false);jb2.setenabled(false);return null;private execution exe;private jbutton jb1,jb2;private jtextarea jta ;private jlabel jl;private probl

14、em problem;private action l = new action();class action implements actionlistenerpublic void actionperformed(actionevent e) if("yes".equals(e.getactioncommand()if(null!=problem.getanswer_yes()problem.getanswer_yes().setistrue(true);else if("no".equals(e.getactioncommand()system.o

15、ut.println("aaa");if(null!=problem.getanswer_no()system.out.println("aaa");problem.getanswer_no().setistrue(true);exe.allreasoning();problem=initproblem();if(problem=null)arraylist<fact> facts=exe.start();string result=""for(int i=0,n=1;i<facts.size();i+)string

16、 des = facts.get(i).getdescribe();if(!"null".equals(des)result+=i+1+"."+des+"n"n+;jl.settext("推理結(jié)果如下:");jta.settext(result);jb1.setenabled(false);jb2.setenabled(false);return;package 專家系統(tǒng)_v2;import java.io.file;import java.io.ioexception;import java.io.unsuppo

17、rtedencodingexception;import .urldecoder;import java.util.arraylist;import java.util.hashmap;import javax.swing.joptionpane;import javax.xml.parsers.documentbuilder;import javax.xml.parsers.documentbuilderfactory;import javax.xml.parsers.parserconfigurationexception;import org.w3c.dom.document;impor

18、t org.w3c.dom.element;import org.w3c.dom.nodelist;import org.xml.sax.saxexception;public class execution public boolean init()try this.initxml(this.getpath(); catch (parserconfigurationexception e) e.printstacktrace(); catch (saxexception e) this.exit(e.getmessage(); catch (ioexception e) e.printsta

19、cktrace(); catch (nullpointerexception e)this.exit("找不到相應(yīng)的xml文件,請(qǐng)檢查xml文件名是否符合規(guī)范");return false;private void initxml(string file) throws parserconfigurationexception, saxexception, ioexceptiondocumentbuilderfactory dbf = documentbuilderfactory.newinstance();documentbuilder builder = dbf.new

20、documentbuilder();document doc=null;trydoc = builder.parse(new file(file);catch(exception e)this.exit(e.getmessage();element root = doc.getdocumentelement(); / 獲取根元素expert_name=root.getattribute("name"); /取得名字/獲取事實(shí)factnodelist allfacts = root.getelementsbytagname("facts");nodelis

21、t onefacts = (element)allfacts.item(0).getelementsbytagname("fact");for(int i=0;i<onefacts.getlength();i+)element onefact = (element)onefacts.item(i);fact fact = new fact();tryfact.setname(onefact.getelementsbytagname("name").item(0).getfirstchild().getnodevalue();fact.setdesc

22、ribe(onefact.getelementsbytagname("describe").item(0).getfirstchild().getnodevalue();catch(nullpointerexception e)this.exit("fact中缺少相應(yīng)標(biāo)簽");facts.put(fact.getname(), fact);/獲取推理reasoningnodelist allreasonings = root.getelementsbytagname("reasonings");nodelist onereasonin

23、gs = (element)allreasonings.item(0).getelementsbytagname("reasoning");for(int i=0;i<onereasonings.getlength();i+)element onereasoning = (element)onereasonings.item(i);reasoning reasoning = new reasoning();nodelist reasons = onereasoning.getelementsbytagname("reason");if(reason

24、s.getlength()=0)this.exit("reasoning中不可以缺少reason標(biāo)簽");for(int j=0;j<reasons.getlength();j+)string name=reasons.item(j).getfirstchild().getnodevalue();if(facts.get(name)!=null)reasoning.getreason().add(facts.get(name);elsethis.exit("reason標(biāo)簽內(nèi)容不正確,沒有對(duì)應(yīng)事實(shí)");nodelist results = oner

25、easoning.getelementsbytagname("result");if(results.getlength()=0)this.exit("reasoning中不可以缺少result標(biāo)簽");for(int j=0;j<results.getlength();j+)string name=results.item(j).getfirstchild().getnodevalue();if(facts.get(name)!=null)reasoning.getresult().add(facts.get(name);elsethis.exi

26、t("result標(biāo)簽內(nèi)容不正確,沒有對(duì)應(yīng)事實(shí)");reasonings.add(reasoning);/獲取問題problemnodelist allproblems = root.getelementsbytagname("problems");nodelist oneproblems = (element)allproblems.item(0).getelementsbytagname("problem");for(int i=0;i<oneproblems.getlength();i+)element oneproble

27、m = (element)oneproblems.item(i);problem problem = new problem();problem.setcontext(oneproblem.getelementsbytagname("context").item(0).getfirstchild().getnodevalue();tryproblem.setpremise(facts.get(oneproblem.getelementsbytagname("premise").item(0).getfirstchild().getnodevalue();

28、catch(exception e)tryproblem.setanswer_yes(facts.get(oneproblem.getelementsbytagname("answer_yes").item(0).getfirstchild().getnodevalue();catch(exception e)tryproblem.setanswer_no(facts.get(oneproblem.getelementsbytagname("answer_no").item(0).getfirstchild().getnodevalue();catch(

29、exception e)problems.add(problem);public void allreasoning()boolean proceed=true;while(proceed)proceed=false;for(reasoning reasoning:reasonings)reasoning.startreasoning();if(reasoning.startreasoning()proceed=true;public arraylist<fact> start()/this.allreasoning();arraylist<fact> reallyfa

30、cts = new arraylist<fact>();for(fact fact:facts.values()if(fact.isistrue()reallyfacts.add(fact);return reallyfacts;private void exit(string passage)joptionpane.showmessagedialog(null, passage);system.exit(0);/查找當(dāng)前路徑private string getpath()string mypath=null;try mypath=urldecoder.decode(executi

31、on.class.getprotectiondomain().getcodesource().getlocation().getfile(), "utf-8"); catch (unsupportedencodingexception e) e.printstacktrace();string path=mypath.substring(1,mypath.lastindexof("/")+1)+"xml/配置文件.xml"return path;public hashmap<string,fact> facts = new

32、 hashmap<string,fact> ();public arraylist<reasoning> reasonings = new arraylist<reasoning>();public arraylist<problem> problems = new arraylist<problem>();public string expert_name;package 專家系統(tǒng)_v2;/* * 存放事實(shí)的類 * author liguanyi * */public class fact private string name;

33、/名字private boolean istrue=false; /是否成立private string describe; /事實(shí)相應(yīng)表述public string getname() return name;public void setname(string name) = name;public boolean isistrue() return istrue;public void setistrue(boolean istrue) this.istrue = istrue;public string getdescribe() return describe;p

34、ublic void setdescribe(string describe) this.describe = describe;package 專家系統(tǒng)_v2;import java.util.arraylist;/表示推理public class reasoning private arraylist<fact> reason = new arraylist<fact>(); /前提事實(shí)private arraylist<fact> result = new arraylist<fact>(); /結(jié)果事實(shí)public arraylist&l

35、t;fact> getreason() return reason;public void setreason(arraylist<fact> reason) this.reason = reason;public arraylist<fact> getresult() return result;public void setresult(arraylist<fact> result) this.result = result;public boolean startreasoning()if(reason.size()=0)return false

36、;for(fact fact:reason)if(!fact.isistrue()return false;for(fact fact:reason)fact.setistrue(false);for(fact fact:result)fact.setistrue(true);return true;package 專家系統(tǒng)_v2;public class problem private fact premise;private string context;private fact answer_yes; /結(jié)果private fact answer_no; /結(jié)果public fact g

37、etpremise() return premise;public void setpremise(fact premise) this.premise = premise;public string getcontext() return context;public void setcontext(string context) this.context = context;public fact getanswer_yes() return answer_yes;public void setanswer_yes(fact answeryes) answer_yes = answerye

38、s;public fact getanswer_no() return answer_no;public void setanswer_no(fact answerno) answer_no = answerno;以下是xml文件(保存事實(shí)庫和規(guī)則庫)中部分內(nèi)容<all name="疾病診斷"><facts><fact><name>fact1</name><describe>咳嗽</describe></fact><fact><name>fact2<

39、/name><describe>胸痛</describe></fact><fact><name>fact3</name><describe>盜汗</describe></fact> <fact><name>fact4</name><describe>食欲不振</describe></fact> <fact><name>fact5</name><describe>消

40、瘦</describe></fact> <fact><name>fact6</name><describe>午后低熱</describe></fact> <fact><name>fact7</name><describe>肺結(jié)核</describe></fact> <fact><name>fact9</name><describe>呼吸困難</describe><

41、/fact> <fact><name>fact10</name><describe>胸腔積液</describe></fact> <fact><name>fact11</name><describe>伴有哮鳴音的呼吸困難</describe></fact> <fact><name>fact12</name><describe>發(fā)作性胸悶咳嗽</describe></fact>

42、 <fact><name>fact13</name><describe>哮喘</describe></fact> <fact> <name>fact14</name> <describe>不盜汗</describe> </fact> <fact> <name>fact15</name> <describe>不咳嗽</describe> </fact> <fact> &l

43、t;name>fact16</name> <describe>沒有伴有哮鳴音的呼吸困難</describe> </fact> <fact> <name>fact17</name> <describe>上腹痛</describe> </fact> <fact> <name>fact18</name> <describe>節(jié)律性、周期性疼痛</describe> </fact> <fact>

44、 <name>fact19</name> <describe>灼疼</describe> </fact> <fact> <name>fact20</name> <describe>鈍痛</describe> </fact> <fact> <name>fact21</name> <describe>消化性潰瘍</describe> </fact> <fact> <name>

45、;fact22</name> <describe>上腹不痛</describe> </fact> <fact> <name>fact23</name> <describe>胸骨后不適</describe> </fact> <fact> <name>fact24</name> <describe>灼燒感</describe></facts><reasonings><reasoning>

46、; <reason>fact6</reason><result>fact7</result></reasoning><reasoning> <reason>fact9</reason><result>fact10</result></reasoning> <reasoning> <reason>fact12</reason> <result>fact13</result> </reasoning&g

47、t; <reasoning> <reason>fact20</reason> <result>fact21</result> </reasoning> <reasoning> <reason>fact27</reason> <result>fact28</result> </reasoning> <reasoning> <reason>fact32</reason> <result>fact33</

48、result> </reasoning> <reasoning> <reason>fact43</reason> <result>fact44</result> </reasoning> <reasoning> <reason>fact47</reason> <result>fact48</result> </reasoning></reasonings><problems><problem><

49、;context>是否咳嗽?</context><answer_yes>fact1</answer_yes> <answer_no>fact15</answer_no></problem> <problem> <premise>fact1</premise><context>是否胸痛?</context><answer_yes>fact2</answer_yes></problem> <problem><

50、premise>fact2</premise><context>是否盜汗?</context><answer_yes>fact3</answer_yes> <answer_no>fact14</answer_no></problem> <problem><premise>fact14</premise><context>是否呼吸困難?</context><answer_yes>fact9</answer_yes>

51、;</problem> <problem><premise>fact3</premise><context>食欲不振?</context><answer_yes>fact4</answer_yes></problem> <problem><premise>fact4</premise><context>消瘦?</context><answer_yes>fact5</answer_yes></problem> <problem><premise>fact5</premise

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論