首页 > 其他 > 详细

朴素贝叶斯法

时间:2016-03-13 11:13:42      阅读:289      评论:0      收藏:0      [点我收藏+]

技术分享

技术分享

技术分享

技术分享

技术分享

 1 // load data
 2 ArffLoader loader = new ArffLoader();
 3 loader.setFile(new File(args[0]));
 4 Instances structure = loader.getStructure();
 5 structure.setClassIndex(structure.numAttributes() - 1);
 6  
 7 // train NaiveBayes
 8 NaiveBayesUpdateable nb = new NaiveBayesUpdateable();
 9 NaiveBayes nb2 = new NaiveBayes();
10 nb.buildClassifier(structure);
11 Instance current;
12 while ((current = loader.getNextInstance(structure)) != null)
13     nb.updateClassifier(current);
14  
15 // output generated model
16 System.out.println(nb);

其中,NaiveBayes类和NaiveBayesUpdateable类的区别在于,后者初始化时训练数据可为空,然后动态添加训练数据,而前者都不可以。

 

参考资料:

  1. 统计学习方法 李航 著
  2. https://en.wikipedia.org/wiki/Naive_Bayes_classifier
  3. zh.wikipedia.org/wiki/贝叶斯定理
  4. http://www.ruanyifeng.com/blog/2013/12/naive_bayes_classifier.html
  5. http://weka.sourceforge.net/doc.stable/

朴素贝叶斯法

原文:http://www.cnblogs.com/lin-xuan/p/5271386.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!