/** * Returns the number of clusters. * * @return the number of clusters */ @Override public int numberOfClusters() { determineNumberOfClusters(); return m_numberOfClusters; }
/** * Singals the end of the updating. */ @Override public void updateFinished() { determineNumberOfClusters(); }
/** * Returns the number of clusters. * * @return the number of clusters */ @Override public int numberOfClusters() { determineNumberOfClusters(); return m_numberOfClusters; }
/** * Singals the end of the updating. */ @Override public void updateFinished() { determineNumberOfClusters(); }
/** * Classifies a given instance. * * @param instance the instance to be assigned to a cluster * @return the number of the assigned cluster as an interger if the class is * enumerated, otherwise the predicted value * @throws Exception if instance could not be classified successfully */ @Override public int clusterInstance(Instance instance) throws Exception { CNode host = m_cobwebTree; CNode temp = null; determineNumberOfClusters(); do { if (host.m_children == null) { temp = null; break; } // host.updateStats(instance, false); temp = host.findHost(instance, true); // host.updateStats(instance, true); if (temp != null) { host = temp; } } while (temp != null); return host.m_clusterNum; }
/** * Classifies a given instance. * * @param instance the instance to be assigned to a cluster * @return the number of the assigned cluster as an interger if the class is * enumerated, otherwise the predicted value * @throws Exception if instance could not be classified successfully */ @Override public int clusterInstance(Instance instance) throws Exception { CNode host = m_cobwebTree; CNode temp = null; determineNumberOfClusters(); do { if (host.m_children == null) { temp = null; break; } // host.updateStats(instance, false); temp = host.findHost(instance, true); // host.updateStats(instance, true); if (temp != null) { host = temp; } } while (temp != null); return host.m_clusterNum; }
/** * Recursively build a string representation of the Cobweb tree * * @param depth depth of this node in the tree * @param text holds the string representation */ protected void dumpTree(int depth, StringBuffer text) { if (depth == 0) { determineNumberOfClusters(); } if (m_children == null) { text.append("\n"); for (int j = 0; j < depth; j++) { text.append("| "); } text.append("leaf " + m_clusterNum + " [" + m_clusterInstances.numInstances() + "]"); } else { for (int i = 0; i < m_children.size(); i++) { text.append("\n"); for (int j = 0; j < depth; j++) { text.append("| "); } text.append("node " + m_clusterNum + " [" + m_clusterInstances.numInstances() + "]"); m_children.get(i).dumpTree(depth + 1, text); } } }
/** * Recursively build a string representation of the Cobweb tree * * @param depth depth of this node in the tree * @param text holds the string representation */ protected void dumpTree(int depth, StringBuffer text) { if (depth == 0) { determineNumberOfClusters(); } if (m_children == null) { text.append("\n"); for (int j = 0; j < depth; j++) { text.append("| "); } text.append("leaf " + m_clusterNum + " [" + m_clusterInstances.numInstances() + "]"); } else { for (int i = 0; i < m_children.size(); i++) { text.append("\n"); for (int j = 0; j < depth; j++) { text.append("| "); } text.append("node " + m_clusterNum + " [" + m_clusterInstances.numInstances() + "]"); m_children.get(i).dumpTree(depth + 1, text); } } }