weka java 教程_WEKA教程完整版(新)详细分解.ppt

这篇教程介绍了如何在Weka中使用Java进行聚类和分类。讲解了如何通过buildClassifier和buildClusterer方法建立批处理分类器和聚类器,如EM算法,并展示了增量式聚类器的训练过程。此外,还提到了如何使用ClusterEvaluation类评估聚类效果。
摘要由CSDN通过智能技术生成

Note on nominal classes: If you're interested in the distribution over all the classes, use the method distributionForInstance(Instance). This method returns a double array with the probability for each class. The returned double value from classifyInstance (or the index in the array returned by distributionForInstance) is just the index for the string values in the attribute. I.e., if you want the string representation for the above returned class label clsLabel, then you can, e.g., print it like this: System.out.println(clsLabel + " -> " + unlabeled.classAttribute().value((int) clsLabel)); Building a Clusterer Batch 和分类器用buildClassifier(Instances) 建立类似,聚类(器)用buildClusterer(Instances) 建立。下列代码片段(code snippet )实现了EM聚类算法,最大迭代次数为100 import weka.clusterers.EM; ... String[] options = new String[2]; options[0] = "-I"; // max. iterations options[1] = "100"; EM clusterer = new EM(); // new instance of clusterer clusterer.setOptions(options); // set the options clusterer.buildClusterer(data); // build the clusterer Building a Clusterer Incremental 实现了weka.clusterers.UpdateableClusterer接口的聚类器可以进行增量聚类。 训练增量式聚类器的过程: Call buildClusterer(Instances) with the structure of the dataset (may or may not contain any actual data rows). Subsequently call the updateClusterer(Instance) method to feed the clusterer one by one. Call updateFinished() after all Instance objects have been processed, for the clusterer to perform additional computations. 示例 // load data ArffLoader loader = new ArffLoader(); loader.setFile(new File("/some/where/data.arff")); Instances structure = loader.getStructure(); ? // train Cobweb Cobweb cw = new Cobweb(); cw.buildClusterer(structure); Instance current; while ((current = loader.getNextInstance(structure)) != null) cw.updateClusterer(current); cw.updateFinished(); Evaluating a clusterer 可用ClusterEvaluation 类评价一个聚类器。以下代码片段输出了算法发现的类的个数。 import weka.clusterers.ClusterEvaluation; import weka.clusterers.Clusterer; ... ClusterEvaluati

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值