File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Others/DataMining_BayesNetwork Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ package DataMining_BayesNetwork ;
2+
3+ import java .text .MessageFormat ;
4+
5+ /**
6+ * 贝叶斯网络场景测试类
7+ *
8+ * @author lyq
9+ *
10+ */
11+ public class Client {
12+ public static void main (String [] args ) {
13+ String dataFilePath = "C:\\ Users\\ lyq\\ Desktop\\ icon\\ input.txt" ;
14+ String attachFilePath = "C:\\ Users\\ lyq\\ Desktop\\ icon\\ attach.txt" ;
15+ // 查询串语句
16+ String queryStr ;
17+ // 结果概率
18+ double result ;
19+
20+ // 查询语句的描述的事件是地震发生了,导致响铃响了,导致接到Mary的电话
21+ queryStr = "E=y,A=y,M=y" ;
22+ BayesNetWorkTool tool = new BayesNetWorkTool (dataFilePath ,
23+ attachFilePath );
24+ result = tool .calProByNetWork (queryStr );
25+
26+ if (result == -1 ) {
27+ System .out .println ("所描述的事件不满足贝叶斯网络的结构,无法求其概率" );
28+ } else {
29+ System .out .println (String .format ("事件%s发生的概率为%s" , queryStr , result ));
30+ }
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments