@Override public double[] getDistribution(Instance inst, Attribute classAtt) throws Exception { if (m_majClassCorrectWeight > m_nbCorrectWeight) { return super.bypassNB(inst, classAtt); } return super.getDistribution(inst, classAtt); }
@Override protected int dumpTree(int depth, int leafCount, StringBuffer buff) { leafCount = super.dumpTree(depth, leafCount, buff); buff.append(" NB adaptive" + m_leafNum); return leafCount; }
@Override public void updateNode(Instance inst) throws Exception { String trueClass = inst.classAttribute().value((int) inst.classValue()); int trueClassIndex = (int) inst.classValue(); if (majorityClass().equals(trueClass)) { m_majClassCorrectWeight += inst.weight(); } if (m_bayes.classifyInstance(inst) == trueClassIndex) { m_nbCorrectWeight += inst.weight(); } super.updateNode(inst); }
@Override public double[] getDistribution(Instance inst, Attribute classAtt) throws Exception { // totalWeight - m_weightSeenAtLastSplitEval is the weight mass // observed by this node's NB model boolean doNB = m_nbWeightThreshold == 0 ? true : (totalWeight() - m_weightSeenAtLastSplitEval > m_nbWeightThreshold); if (doNB) { return m_bayes.distributionForInstance(inst); } return super.getDistribution(inst, classAtt); }
/** * Create a new learning node (either majority class, naive Bayes or naive * Bayes adaptive) * * @return a new learning node * @throws Exception if a problem occurs */ protected ActiveHNode newLearningNode() throws Exception { ActiveHNode newChild; if (m_leafStrategy == LEAF_MAJ_CLASS) { newChild = new ActiveHNode(); } else if (m_leafStrategy == LEAF_NB) { newChild = new NBNode(m_header, m_nbThreshold); } else { newChild = new NBNodeAdaptive(m_header, m_nbThreshold); } return newChild; }
@Override public void updateNode(Instance inst) throws Exception { String trueClass = inst.classAttribute().value((int) inst.classValue()); int trueClassIndex = (int) inst.classValue(); if (majorityClass().equals(trueClass)) { m_majClassCorrectWeight += inst.weight(); } if (m_bayes.classifyInstance(inst) == trueClassIndex) { m_nbCorrectWeight += inst.weight(); } super.updateNode(inst); }
@Override public double[] getDistribution(Instance inst, Attribute classAtt) throws Exception { // totalWeight - m_weightSeenAtLastSplitEval is the weight mass // observed by this node's NB model boolean doNB = m_nbWeightThreshold == 0 ? true : (totalWeight() - m_weightSeenAtLastSplitEval > m_nbWeightThreshold); if (doNB) { return m_bayes.distributionForInstance(inst); } return super.getDistribution(inst, classAtt); }
/** * Create a new learning node (either majority class, naive Bayes or naive * Bayes adaptive) * * @return a new learning node * @throws Exception if a problem occurs */ protected ActiveHNode newLearningNode() throws Exception { ActiveHNode newChild; if (m_leafStrategy == LEAF_MAJ_CLASS) { newChild = new ActiveHNode(); } else if (m_leafStrategy == LEAF_NB) { newChild = new NBNode(m_header, m_nbThreshold); } else { newChild = new NBNodeAdaptive(m_header, m_nbThreshold); } return newChild; }
@Override public double[] getDistribution(Instance inst, Attribute classAtt) throws Exception { if (m_majClassCorrectWeight > m_nbCorrectWeight) { return super.bypassNB(inst, classAtt); } return super.getDistribution(inst, classAtt); }
@Override protected int dumpTree(int depth, int leafCount, StringBuffer buff) { leafCount = super.dumpTree(depth, leafCount, buff); buff.append(" NB adaptive" + m_leafNum); return leafCount; }