int[] countOutcomeClasses, List<DoubleVector> features,
List<DoubleVector> outcome) {
if (featureTypes[featureIndex].isNominal()) {
TIntObjectHashMap<int[]> featureValueOutcomeCount = new TIntObjectHashMap<>();
TIntIntHashMap rowSums = new TIntIntHashMap();
int numFeatures = 0;
Iterator<DoubleVector> featureIterator = features.iterator();
Iterator<DoubleVector> outcomeIterator = outcome.iterator();
while (featureIterator.hasNext()) {
DoubleVector feature = featureIterator.next();
DoubleVector out = outcomeIterator.next();
int classIndex = getOutcomeClassIndex(out);
int nominalFeatureValue = (int) feature.get(featureIndex);
int[] is = featureValueOutcomeCount.get(nominalFeatureValue);
if (is == null) {
is = new int[outcomeDimension];
featureValueOutcomeCount.put(nominalFeatureValue, is);
}
is[classIndex]++;
rowSums.put(nominalFeatureValue, rowSums.get(nominalFeatureValue) + 1);
numFeatures++;
}
double entropySum = 0d;
// now we can calculate the entropy
TIntObjectIterator<int[]> iterator = featureValueOutcomeCount.iterator();
while (iterator.hasNext()) {
iterator.advance();
int[] outcomeCounts = iterator.value();
double condEntropy = rowSums.get(iterator.key()) / (double) numFeatures
* getEntropy(outcomeCounts);
entropySum += condEntropy;
}
return new Split(featureIndex, overallEntropy - entropySum);
} else {