开发者

Naive Bayes Implementation and infering data from the class labels

Does anybody have any pointers to Naive Bayes Classifier Implementation preferably in C. I have 5 dimensional binary dataset. The clas开发者_开发知识库s labels are also binary. I used Naive Bayes Classifier in Matlab with good results. However, is there any machine learning algorithm and its implementation which allows me to infer data from the class labels? Here in this case I want five dimensional binary data inferred from a binary class label. A sample of data is [1 1 0 1 0] and class is 0.


As you have a binary dataset, here is a nice implementation using C:

http://users.ics.tkk.fi/jhollmen/BernoulliMix/

It is a open source software that we are using currently in our course, you can actually check how he implemented the algorithm.

And about the question you made, here is my understanding.

What naive bayes classifier(NBC) does is to predict P(C|X) given some data and label. According to Bayes' theorem,

P(C|X) = \frac{P(X|C)P(C)}{P(X)}

which means that all you can do with predict the class of unknown data. Conversely, what you want to do there is P(X|C). Therefore, you can train your model like this,

P(X|C) = \frac{P(C|X)P(X)}{P(C)}

Accordingly, you have to assume distribution for your data...and stuff like that, therefore,it might be so accurate if you have a wrong assumption with your data. In you case, you have binary attributes X that is wanted be estimated from the label class, if you assume the attributes are independent, what you need to is like this,

P(C|X_1,X_2,X_3,X_4,X_5) \proportional P(X_1|C)P(X_2|C)P(X_3|C)P(X_4|C)P(X_5|C)P(C)

which is not so easy to solve.....


Hava a look at this package of the R-project:

http://www.stat.ucl.ac.be/ISdidactique/Rhelp/library/e1071/html/naiveBayes.html

http://cran.r-project.org/web/packages/e1071/index.html

You have tagged [C]: it is possible to link R with your own C-programs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜