List of usage examples for weka.clusterers XMeans setMaxKMeans
public void setMaxKMeans(int i)
From source file:org.montp2.m1decol.ter.clustering.XMeansClustering.java
License:Open Source License
public Clusterer computeClustering(String inPath, String outPath, Properties propertiesCluster) throws Exception { Instances inputInstances = WekaUtils.loadARFF(inPath); EuclideanDistance euclideanDistance = new EuclideanDistance(); euclideanDistance.setAttributeIndices("first-last"); euclideanDistance.setDontNormalize(false); euclideanDistance.setInvertSelection(false); XMeans xmeans = new XMeans(); xmeans.setMaxIterations(500);//from ww w .java 2 s . c o m xmeans.setSeed(10); xmeans.setMinNumClusters(5); xmeans.setMaxNumClusters(12); xmeans.setMaxKMeans(1000); xmeans.setMaxKMeansForChildren(1000); xmeans.setBinValue(1.0); xmeans.setCutOffFactor(0.5); xmeans.setDebugLevel(0); xmeans.setMaxIterations(1); xmeans.buildClusterer(inputInstances); Enumeration<Instance> e = inputInstances.enumerateInstances(); while (e.hasMoreElements()) { Instance ins = e.nextElement(); int cluster_num = xmeans.clusterInstance(ins); System.out.println(ins.toString()); System.out.println(cluster_num); } WekaUtils.saveModel(xmeans, outPath); return xmeans; }