List of usage examples for weka.clusterers HierarchicalClusterer graph
@Override public String graph() throws Exception
From source file:Clustering.WekaHierarchicalClustererWrapper.java
@Override public String cluster(HashMap<String, List> data) { try {//from ww w .j a v a 2 s . com File arff = m_ArffExporter.getArff(data); if (arff == null) return null; FileInputStream is = new FileInputStream(arff.getAbsolutePath()); Instances instances = ConverterUtils.DataSource.read(is); is.close(); HierarchicalClusterer cl = new HierarchicalClusterer(); String[] options = new String[6]; options[0] = "-N"; // number of clusters should be "1" options[1] = "1"; options[2] = "-L"; // linking type options[3] = m_LinkType; options[4] = "-A"; options[5] = m_DistanceFunction; cl.setOptions(options); cl.buildClusterer(instances); String newickString = cl.graph(); if (!arff.delete()) arff.deleteOnExit(); return newickString; } catch (Exception ex) { //System.out.println( "[EXCEPTION] " + ex.toString() ); m_LastErrorMessage = ex.getMessage(); return null; } }