Example usage for weka.clusterers FarthestFirst buildClusterer

List of usage examples for weka.clusterers FarthestFirst buildClusterer

Introduction

In this page you can find the example usage for weka.clusterers FarthestFirst buildClusterer.

Prototype

@Override
public void buildClusterer(Instances data) throws Exception 

Source Link

Document

Generates a clusterer.

Usage

From source file:clusterer.SimpleKMeansWithSilhouette.java

License:Open Source License

/**
 * Initialize with the fartherst first centers
 * //from w w w .  j a v a  2 s  .c  o  m
 * @param data the training data
 * @throws Exception if a problem occurs
 */
protected void farthestFirstInit(Instances data) throws Exception {
    FarthestFirst ff = new FarthestFirst();
    ff.setNumClusters(m_NumClusters);
    ff.buildClusterer(data);

    m_ClusterCentroids = ff.getClusterCentroids();
}

From source file:net.sf.mzmine.modules.peaklistmethods.dataanalysis.clustering.farthestfirst.FarthestFirstClusterer.java

License:Open Source License

@Override
public ClusteringResult performClustering(Instances dataset, ParameterSet parameters) {

    List<Integer> clusters = new ArrayList<Integer>();
    String[] options = new String[2];
    FarthestFirst clusterer = new FarthestFirst();

    int numberOfGroups = parameters.getParameter(FarthestFirstClustererParameters.numberOfGroups).getValue();
    options[0] = "-N";
    options[1] = String.valueOf(numberOfGroups);

    try {/*  w  w w.  j av  a  2  s.c o  m*/
        clusterer.setOptions(options);
        clusterer.buildClusterer(dataset);
        Enumeration<?> e = dataset.enumerateInstances();
        while (e.hasMoreElements()) {
            clusters.add(clusterer.clusterInstance((Instance) e.nextElement()));
        }
        ClusteringResult result = new ClusteringResult(clusters, null, clusterer.numberOfClusters(),
                parameters.getParameter(EMClustererParameters.visualization).getValue());
        return result;
    } catch (Exception ex) {
        logger.log(Level.SEVERE, null, ex);
        return null;
    }
}