朴树贝叶斯算法及截图(共12页).docx
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《朴树贝叶斯算法及截图(共12页).docx》由会员分享,可在线阅读,更多相关《朴树贝叶斯算法及截图(共12页).docx(12页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上/ naiveBayesClassify.cpp : 定义控制台应用程序的入口点。/#include stdafx.h#include#include#include#include#includeusing namespace std;/save the training datatypedef vectorvector strDVect;/save all possible condition probabilitystypedef mapstring,mapstring,map thriMap;/service for thriMaptypedef mapstr
2、ing,map doubleMap;typedef map strMap;/save the kind of aim attribute valuetypedef map aimMap;/kind of every attribute including aim attribute valuetypedef map attMap;/const for denominator and numeratordouble K = 1;/sampletypedef vector sampleVect;/check the three dimensions map and return 4 statesi
3、nt existRecord(thriMap prob,string aimValue,string attName,string attValue)thriMap:const_iterator iterThri = prob.find(aimValue);if(iterThri = prob.end()return 1;doubleMap:const_iterator iterDouble = iterThri-second.find(attName);if(iterDouble = iterThri-second.end()return 2;strMap:const_iterator it
4、erSingle = iterDouble-second.find(attValue);if(iterSingle = iterDouble-second.end()return 3;return 4;void show(thriMap prob)thriMap:iterator iterThri = prob.begin();for(;iterThri != prob.end(); iterThri+)doubleMap:iterator iterDouble = iterThri-second.begin();for(;iterDouble != iterThri-second.end()
5、; iterDouble+)strMap:iterator iterSingle = iterDouble-second.begin();for(;iterSingle != iterDouble-second.end(); iterSingle+)cout first first first second endl;/get all possible statistics/three dimensions hash prob, first key notes aim attribute value,second key notes refence attribute name,/third
6、key notes reference attribute value, the value notes the refence attribute value numbervoid getConditionStat(strDVect datas,thriMap &prob,aimMap &aimNum)int i,j,k,m,n;m = datas.size();n = datas0.size(); doubleMap doubleMapIns;strMap strMapIns;thriMap:iterator iterThri;doubleMap:iterator iterDouble;f
7、or(i=1; i m; i+)/save all possible statisticsfor(j = 0; j second.insert(make_pair(datas0j,strMapIns);break;case 3:prob.find(datasin-1)-second.find(datas0j)-second.insert(make_pair(datasij,1);break;case 4:prob.find(datasin-1)-second.find(datas0j)-second.find(datasij)-second+;break;/save the kind of a
8、im attribute valueif(aimNum.find(datasin-1) != aimNum.end()aimNum.find(datasin-1)-second+;elseaimNum.insert(make_pair(datasin-1,1);void getConditionProb(thriMap &prob,aimMap aimNum,attMap attKind) /save all possible condition probabilitysthriMap:iterator iterThri = prob.begin();for(;iterThri != prob
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 朴树 贝叶斯 算法 截图 12
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内