private double cuScoreForBestTwoMerged(CNode merged, CNode a, CNode b, Instance newInstance) throws Exception { double mergedCU = -Double.MAX_VALUE; // consider merging the best and second // best. merged.m_clusterInstances = new Instances(m_clusterInstances, 1); merged.addChildNode(a); merged.addChildNode(b); merged.updateStats(newInstance, false); // add new instance to stats // remove the best and second best nodes m_children.remove(m_children.indexOf(a)); m_children.remove(m_children.indexOf(b)); m_children.add(merged); mergedCU = categoryUtility(); // restore the status quo merged.updateStats(newInstance, true); m_children.remove(m_children.indexOf(merged)); m_children.add(a); m_children.add(b); return mergedCU; }
private double cuScoreForBestTwoMerged(CNode merged, CNode a, CNode b, Instance newInstance) throws Exception { double mergedCU = -Double.MAX_VALUE; // consider merging the best and second // best. merged.m_clusterInstances = new Instances(m_clusterInstances, 1); merged.addChildNode(a); merged.addChildNode(b); merged.updateStats(newInstance, false); // add new instance to stats // remove the best and second best nodes m_children.remove(m_children.indexOf(a)); m_children.remove(m_children.indexOf(b)); m_children.add(merged); mergedCU = categoryUtility(); // restore the status quo merged.updateStats(newInstance, true); m_children.remove(m_children.indexOf(merged)); m_children.add(a); m_children.add(b); return mergedCU; }
/** * Temporarily adds a new instance to each of this nodes children in turn * and computes the category utility. * * @param newInstance the new instance to evaluate * @return an array of category utility values---the result of considering * each child in turn as a host for the new instance * @throws Exception if an error occurs */ private double[] cuScoresForChildren(Instance newInstance) throws Exception { // look for a host in existing children double[] categoryUtils = new double[m_children.size()]; // look for a home for this instance in the existing children for (int i = 0; i < m_children.size(); i++) { CNode temp = m_children.get(i); // tentitively add the new instance to this child temp.updateStats(newInstance, false); categoryUtils[i] = categoryUtility(); // remove the new instance from this child temp.updateStats(newInstance, true); } return categoryUtils; }
double bestHostCU = categoryUtility(); CNode finalBestHost = newLeaf; splitPlusNewLeafCU = categoryUtility(); // split + new leaf
double bestHostCU = categoryUtility(); CNode finalBestHost = newLeaf; splitPlusNewLeafCU = categoryUtility(); // split + new leaf
if (categoryUtility() < m_cutoff) {
if (categoryUtility() < m_cutoff) {
/** * Temporarily adds a new instance to each of this nodes children in turn * and computes the category utility. * * @param newInstance the new instance to evaluate * @return an array of category utility values---the result of considering * each child in turn as a host for the new instance * @throws Exception if an error occurs */ private double[] cuScoresForChildren(Instance newInstance) throws Exception { // look for a host in existing children double[] categoryUtils = new double[m_children.size()]; // look for a home for this instance in the existing children for (int i = 0; i < m_children.size(); i++) { CNode temp = m_children.get(i); // tentitively add the new instance to this child temp.updateStats(newInstance, false); categoryUtils[i] = categoryUtility(); // remove the new instance from this child temp.updateStats(newInstance, true); } return categoryUtils; }