一、两个明确
(1)weather数据集:它是weka里自带的数据集,格式为weather.nominal.arff或weather.numeric.arff,前者表示的是全是名称型属性,后者表示的带有数值型属性。使用的时候,直接在 .\Weka-3-8-4\data路径下调。
(2)NaiveBayesSimple.java:顾名思义,它是简单朴素贝叶斯对应的java类,用于实现简单朴素贝叶斯。
二、eclipse中导入weka源码
步骤如下:
(1)打开eclipse,新建一个java project,这里起名为wekaTest。
weather数据集如何放到NaiveBayesSimple.java上跑?
(2)导入weka源码,先将weka-src这个jar包解压,在解压后的文件夹里找main文件夹下的weka文件夹,直接将weka文件Ctrl C、Ctrl V到eclipse中的src包下,发现有报错。(之所以报错,是因为没把项目中别人打包好的jar包给导入,打包好的jar包一般放在lib文件夹下)
weather数据集如何放到NaiveBayesSimple.java上跑?
weather数据集如何放到NaiveBayesSimple.java上跑?
weather数据集如何放到NaiveBayesSimple.java上跑?
(3)找到别人打包的jar包,在wekaTest项目下,右键,Build Path→Add External Archives,进入JAR Selection,将jar包全选,打开即可。神奇地发现,报错没有了。
weather数据集如何放到NaiveBayesSimple.java上跑?
weather数据集如何放到NaiveBayesSimple.java上跑?
weather数据集如何放到NaiveBayesSimple.java上跑?
weather数据集如何放到NaiveBayesSimple.java上跑?
weather数据集如何放到NaiveBayesSimple.java上跑?
(4)将现有的NaiveBayesSimple.java直接拖到weka.classifiers.bayes包下。(原先weka.classifiers.bayes包下并没有NaiveBayesSimple.java)
weather数据集如何放到NaiveBayesSimple.java上跑?
三、weather数据集如何放到NaiveBayesSimple.java上跑
打开NaiveBayesSimple.java,菜单run→run configurations,设定Arguments为

-t weather数据集路径

,最后点击run,运行即可。
weather数据集如何放到NaiveBayesSimple.java上跑?
运行结果:

weather数据集如何放到NaiveBayesSimple.java上跑?

相关文章:

  • 2021-10-14
  • 2021-04-24
  • 2021-07-27
  • 2021-07-14
  • 2021-05-11
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
猜你喜欢
  • 2021-04-07
  • 2021-05-30
  • 2021-12-29
  • 2022-12-23
  • 2021-10-21
  • 2021-12-12
  • 2021-08-12
相关资源
相似解决方案