Skip to content

Commit 1eb1d5c

Browse files
author
linyiqun
committed
树型朴素贝叶斯算法测试类
树型朴素贝叶斯算法测试类
1 parent c671960 commit 1eb1d5c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Others/DataMining_TAN/Client.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package DataMining_TAN;
2+
3+
/**
4+
* TAN树型朴素贝叶斯算法
5+
*
6+
* @author lyq
7+
*
8+
*/
9+
public class Client {
10+
public static void main(String[] args) {
11+
String filePath = "C:\\Users\\lyq\\Desktop\\icon\\input.txt";
12+
// 条件查询语句
13+
String queryStr;
14+
// 分类结果概率1
15+
double classResult1;
16+
// 分类结果概率2
17+
double classResult2;
18+
19+
TANTool tool = new TANTool(filePath);
20+
queryStr = "OutLook=Sunny,Temperature=Hot,Humidity=High,Wind=Weak,PlayTennis=No";
21+
classResult1 = tool.calHappenedPro(queryStr);
22+
23+
queryStr = "OutLook=Sunny,Temperature=Hot,Humidity=High,Wind=Weak,PlayTennis=Yes";
24+
classResult2 = tool.calHappenedPro(queryStr);
25+
26+
System.out.println(String.format("类别为%s所求得的概率为%s", "PlayTennis=No",
27+
classResult1));
28+
System.out.println(String.format("类别为%s所求得的概率为%s", "PlayTennis=Yes",
29+
classResult2));
30+
if (classResult1 > classResult2) {
31+
System.out.println("分类类别为PlayTennis=No");
32+
} else {
33+
System.out.println("分类类别为PlayTennis=Yes");
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)