List of usage examples for weka.clusterers HierarchicalClusterer getNumClusters
public int getNumClusters()
From source file:net.sf.mzmine.modules.peaklistmethods.dataanalysis.clustering.hierarchical.HierarClusterer.java
License:Open Source License
@Override public ClusteringResult performClustering(Instances dataset, ParameterSet parameters) { HierarchicalClusterer clusterer = new HierarchicalClusterer(); String[] options = new String[5]; LinkType link = parameters.getParameter(HierarClustererParameters.linkType).getValue(); DistanceType distanceType = parameters.getParameter(HierarClustererParameters.distanceType).getValue(); options[0] = "-L"; options[1] = link.name();// w w w. j av a 2 s. c o m options[2] = "-A"; switch (distanceType) { case EUCLIDIAN: options[3] = "weka.core.EuclideanDistance"; break; case CHEBYSHEV: options[3] = "weka.core.ChebyshevDistance"; break; case MANHATTAN: options[3] = "weka.core.ManhattanDistance"; break; case MINKOWSKI: options[3] = "weka.core.MinkowskiDistance"; break; } options[4] = "-P"; try { clusterer.setOptions(options); clusterer.setPrintNewick(true); clusterer.buildClusterer(dataset); // clusterer.graph() gives only the first cluster and in the case // there // are more than one cluster the variables in the second cluster are // missing. // I'm using clusterer.toString() which contains all the clusters in // Newick format. ClusteringResult result = new ClusteringResult(null, clusterer.toString(), clusterer.getNumClusters(), null); return result; } catch (Exception ex) { logger.log(Level.SEVERE, null, ex); return null; } }