int help2 = second;
second = first;
first = help2;
}
m_Range = new Range(Range.indicesToRangeList(firstInds));
m_Range.setUpper(data.numClasses() - 1);
Range secondRange = new Range(Range.indicesToRangeList(secondInds));
secondRange.setUpper(data.numClasses() - 1);
// Change the class labels and build the classifier
MakeIndicator filter = new MakeIndicator();
filter.setAttributeIndex("" + (data.classIndex() + 1));
filter.setValueIndices(m_Range.getRanges());
filter.setNumeric(false);
filter.setInputFormat(data);
m_FilteredClassifier = new FilteredClassifier();
if (data.numInstances() > 0) {
m_FilteredClassifier.setClassifier(Classifier.makeCopies(classifier, 1)[0]);
} else {
m_FilteredClassifier.setClassifier(new weka.classifiers.rules.ZeroR());
}
m_FilteredClassifier.setFilter(filter);
// Save reference to hash table at current node
m_classifiers=table;
if (!m_classifiers.containsKey( getString(firstInds) + "|" + getString(secondInds))) {
m_FilteredClassifier.buildClassifier(data);
m_classifiers.put(getString(firstInds) + "|" + getString(secondInds), m_FilteredClassifier);
} else {
m_FilteredClassifier=(FilteredClassifier)m_classifiers.get(getString(firstInds) + "|" +
getString(secondInds));
}
// Create two successors if necessary
m_FirstSuccessor = new DataNearBalancedND();
if (first == 1) {
m_FirstSuccessor.m_Range = m_Range;
} else {
RemoveWithValues rwv = new RemoveWithValues();
rwv.setInvertSelection(true);
rwv.setNominalIndices(m_Range.getRanges());
rwv.setAttributeIndex("" + (data.classIndex() + 1));
rwv.setInputFormat(data);
Instances firstSubset = Filter.useFilter(data, rwv);
m_FirstSuccessor.generateClassifierForNode(firstSubset, m_Range,
rand, classifier, m_classifiers,
instsNumAllClasses);
}
m_SecondSuccessor = new DataNearBalancedND();
if (second == 1) {
m_SecondSuccessor.m_Range = secondRange;
} else {
RemoveWithValues rwv = new RemoveWithValues();
rwv.setInvertSelection(true);
rwv.setNominalIndices(secondRange.getRanges());
rwv.setAttributeIndex("" + (data.classIndex() + 1));
rwv.setInputFormat(data);
Instances secondSubset = Filter.useFilter(data, rwv);
m_SecondSuccessor = new DataNearBalancedND();