= Naive Bayes Classifier =
"A Bayes classifier is a simple probabilistic classifier based on applying Bayes' theorem (from Bayesian statistics)" -- Wikipedia (http://en.wikipedia.org/wiki/Naive_Bayes_classifier)
It is mainly used in artificial intelligence.
== How to use the Naive Bayes Classifier ==
The Naive Bayes Classifier needs data to function. The data is contained in a simple text file. Floats are used to represent every data.
In my example, the bayesianClassifierValues.txt contains the following values :
1.0 2.0 1.0
2.0 1.0 1.0
1.0 2.0 0.0
0.0 0.0 0.0
---------Beware, it won't work if there is an empty line at the end of the file-------
The input or situation data is contained into the n - 1 first columns. In this case, it is the first and second column.
The output observed depending on the situation is the last column.
For example, these data contain situations observed by a Boss in a 2D scroller video game.
- The first column is the relative position of his opponent on the X axis.
- The second column is the relative position of his opponent on the Y axis.
- The last column (the output) is a boolean representing if the opponent is hurt or not.
=== Domains ===
A Bayes classifier needs discrete values to work properly. For each column, a domain has to be associated.
Each of these domains contains the minimum value, maximum value and the number of values between them.
For example, the domain for the first column (the relative position of the opponent on the X axis) is defined like this :
Domain(0.0, 2.0, 3)
The minimum value is 0.0 and maximum value is 2.0. The number of values between them are 3. Hence, the conversion is defined like this :
Discrete value = ((value - min) * number of values) / (max - min)
0 = ((0.5 - 0.0) * 3 / (2.0 - 0.0)
1 = ((0.67 - 0.0) * 3 / (2.0 - 0.0)
1 = ((1.32 - 0.0) * 3 / (2.0 - 0.0)
2 = ((1.34 - 0.0) * 3 / (2.0 - 0.0)
Approximatively, the domains for the first column are these :
[0, 0.666[ = 0
[0.666, 1.333[ = 1
[1.333, 2.0[ = 2
Changing the number of values between the minimum and maximum can affect greatly the results. Test with multiple values for better results.
=== BayesianClassifier ===
The BayesianClassifier is capable of calculating the most probable output depending of the input.
It is possible to add new raw data at runtime and have a better probabilistic classifier.
=== ActionClassifier ===
The ActionClassifier is capable of calculating the best action to perform to obtain a certain output.
It is possible to add new raw data at runtime and have a better probabilistic classifier.
It uses the BayesianClassifier but it has 1 more column. The data is still contained in a simple text file.
In my example, the actionClassifierValues.txt contains the following values :
1.0 2.0 1.0 1.0
2.0 1.0 1.0 1.0
1.0 2.0 0.0 0.0
0.0 0.0 0.0 0.0
---------Beware, it won't work if there is an empty line at the end of the file-------
The input or situation data is contained into the n - 2 first columns. In this case, it is the first and second column.
The output observed depending on the situation is the n - 1 column or in this case, the third column.
The action done in this situation (input) obtaining the output is the last column.
For example, these data contain situations observed by a Boss in a 2D scroller video game.
- The first column is the relative position of his opponent on the X axis.
- The second column is the relative position of his opponent on the Y axis.
- The third column (the output) is a boolean representing if the opponent is hurt or not.
- The last column (the action) is a number representing the action done by the Boss. A C++ enumeration is recommended.
没有合适的资源?快使用搜索试试~ 我知道了~
google贝叶斯分类器代码
共28个文件
svn-base:11个
txt:4个
cpp:4个
5星 · 超过95%的资源 需积分: 4 12 下载量 21 浏览量
2013-07-15
19:08:01
上传
评论 1
收藏 27KB ZIP 举报
温馨提示
谷歌实现的朴素贝叶斯分类器,C++版本的,代码很好,注释详细,可以使用的。
资源推荐
资源详情
资源评论
收起资源包目录
naive-bayes-classifier-src.zip (28个子文件)
src
ActionClassifier.h 2KB
.svn
tmp
props
prop-base
text-base
props
all-wcprops 754B
entries 1KB
prop-base
text-base
Main.cpp.svn-base 4KB
Domain.cpp.svn-base 864B
BayesianClassifier.h.svn-base 5KB
BayesianClassifier.cpp.svn-base 9KB
ActionClassifier.cpp.svn-base 2KB
Domain.h.svn-base 2KB
ActionClassifier.h.svn-base 2KB
Main.cpp 4KB
ActionClassifier.cpp 2KB
Domain.cpp 864B
Domain.h 2KB
data
bayesianClassifierValues.txt 47B
.svn
tmp
props
prop-base
text-base
props
all-wcprops 460B
entries 731B
prop-base
text-base
actionClassifierValues.txt.svn-base 63B
newBayesianClassifierValues.txt.svn-base 11B
bayesianClassifierValues.txt.svn-base 47B
newBayesianClassifierValues.txt 11B
actionClassifierValues.txt 63B
BayesianClassifier.cpp 9KB
BayesianClassifier.h 5KB
doc
.svn
tmp
props
prop-base
text-base
props
all-wcprops 154B
entries 381B
prop-base
text-base
README.txt.svn-base 4KB
README.txt 4KB
共 28 条
- 1
资源评论
- yoeyoe19922014-05-09为什么我下了不能用啊,有好多错误,不知道是我自己的问题还是程序的问题,如果看到评论的话,可以帮我解决一下吗?毕竟积分好贵啊%>_<%
- valiantzh2013-09-12朴素贝叶斯分类器,可以使用
- ni_mamagea2013-11-21资源还是挺不错的,虽然分类正确率还不算高,但是运行没有问题,就是要的积分有点多。。。。
weihua_zheng
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功