/** * Main method. * * @param argv the commandline options */ public static void main(String[] argv) { runClusterer(new Cobweb(), argv); } }
/** * default constructor */ public Cobweb() { super(); m_SeedDefault = 42; setSeed(m_SeedDefault); }
/** * Returns the number of clusters. * * @return the number of clusters */ @Override public int numberOfClusters() { determineNumberOfClusters(); return m_numberOfClusters; }
/** * Builds the clusterer. * * @param data the training instances. * @throws Exception if something goes wrong. */ @Override public void buildClusterer(Instances data) throws Exception { m_numberOfClusters = -1; m_cobwebTree = null; m_numberSplits = 0; m_numberMerges = 0; // can clusterer handle the data? getCapabilities().testWithFail(data); // randomize the instances data = new Instances(data); if (getSeed() >= 0) { data.randomize(new Random(getSeed())); } for (int i = 0; i < data.numInstances(); i++) { updateClusterer(data.instance(i)); } updateFinished(); }
if (optionString.length() != 0) { Double temp = new Double(optionString); setAcuity(temp.doubleValue()); } else { m_acuity = 1.0; if (optionString.length() != 0) { Double temp = new Double(optionString); setCutoff(temp.doubleValue()); } else { m_cutoff = 0.01 * Cobweb.m_normal; setSaveInstanceData(Utils.getFlag("save-data", options));
/** * Returns a string describing this clusterer * * @return a description of the evaluator suitable for displaying in the * explorer/experimenter gui */ public String globalInfo() { return "Class implementing the Cobweb and Classit clustering algorithms.\n\n" + "Note: the application of node operators (merging, splitting etc.) in " + "terms of ordering and priority differs (and is somewhat ambiguous) " + "between the original Cobweb and Classit papers. This algorithm always " + "compares the best host, adding a new leaf, merging the two best hosts, " + "and splitting the best host when considering where to place a new " + "instance.\n\n" + "For more information see:\n\n" + getTechnicalInformation().toString(); }
/** * Returns a description of the clusterer as a string. * * @return a string describing the clusterer. */ @Override public String toString() { StringBuffer text = new StringBuffer(); if (m_cobwebTree == null) { return "Cobweb hasn't been built yet!"; } else { m_cobwebTree.dumpTree(0, text); return "Number of merges: " + m_numberMerges + "\nNumber of splits: " + m_numberSplits + "\nNumber of clusters: " + numberOfClusters() + "\n" + text.toString() + "\n\n"; } }
/** * Gets the current settings of Cobweb. * * @return an array of strings suitable for passing to setOptions() */ @Override public String[] getOptions() { Vector<String> result = new Vector<String>(); result.add("-A"); result.add("" + m_acuity); result.add("-C"); result.add("" + m_cutoff); if (getSaveInstanceData()) { result.add("-save-data"); } Collections.addAll(result, super.getOptions()); return result.toArray(new String[result.size()]); }
/** * Builds the clusterer. * * @param data the training instances. * @throws Exception if something goes wrong. */ @Override public void buildClusterer(Instances data) throws Exception { m_numberOfClusters = -1; m_cobwebTree = null; m_numberSplits = 0; m_numberMerges = 0; // can clusterer handle the data? getCapabilities().testWithFail(data); // randomize the instances data = new Instances(data); if (getSeed() >= 0) { data.randomize(new Random(getSeed())); } for (int i = 0; i < data.numInstances(); i++) { updateClusterer(data.instance(i)); } updateFinished(); }
if (optionString.length() != 0) { Double temp = new Double(optionString); setAcuity(temp.doubleValue()); } else { m_acuity = 1.0; if (optionString.length() != 0) { Double temp = new Double(optionString); setCutoff(temp.doubleValue()); } else { m_cutoff = 0.01 * Cobweb.m_normal; setSaveInstanceData(Utils.getFlag("save-data", options));
/** * Returns a string describing this clusterer * * @return a description of the evaluator suitable for displaying in the * explorer/experimenter gui */ public String globalInfo() { return "Class implementing the Cobweb and Classit clustering algorithms.\n\n" + "Note: the application of node operators (merging, splitting etc.) in " + "terms of ordering and priority differs (and is somewhat ambiguous) " + "between the original Cobweb and Classit papers. This algorithm always " + "compares the best host, adding a new leaf, merging the two best hosts, " + "and splitting the best host when considering where to place a new " + "instance.\n\n" + "For more information see:\n\n" + getTechnicalInformation().toString(); }
/** * Returns a description of the clusterer as a string. * * @return a string describing the clusterer. */ @Override public String toString() { StringBuffer text = new StringBuffer(); if (m_cobwebTree == null) { return "Cobweb hasn't been built yet!"; } else { m_cobwebTree.dumpTree(0, text); return "Number of merges: " + m_numberMerges + "\nNumber of splits: " + m_numberSplits + "\nNumber of clusters: " + numberOfClusters() + "\n" + text.toString() + "\n\n"; } }
/** * Gets the current settings of Cobweb. * * @return an array of strings suitable for passing to setOptions() */ @Override public String[] getOptions() { Vector<String> result = new Vector<String>(); result.add("-A"); result.add("" + m_acuity); result.add("-C"); result.add("" + m_cutoff); if (getSaveInstanceData()) { result.add("-save-data"); } Collections.addAll(result, super.getOptions()); return result.toArray(new String[result.size()]); }
/** * Main method. * * @param argv the commandline options */ public static void main(String[] argv) { runClusterer(new Cobweb(), argv); } }
/** * Returns the number of clusters. * * @return the number of clusters */ @Override public int numberOfClusters() { determineNumberOfClusters(); return m_numberOfClusters; }
/** * default constructor */ public Cobweb() { super(); m_SeedDefault = 42; setSeed(m_SeedDefault); }
/** * Singals the end of the updating. */ @Override public void updateFinished() { determineNumberOfClusters(); }
/** * Singals the end of the updating. */ @Override public void updateFinished() { determineNumberOfClusters(); }