double SymmetricUncertaintyCalculator::calculateUncertainty(const DataFrame& df1, int factorIndex1, const DataFrame& df2, int factorIndex2) { assert(df1.isNominal(factorIndex1)); assert(df2.isNominal(factorIndex2)); double hy = _calculateEntropy(df1, factorIndex1); double hyx = _calculateConditionalEntropy(df1, factorIndex1, df2, factorIndex2); double gain = hy - hyx; double hx = _calculateEntropy(df2, factorIndex2); if (hy + hx == 0.0) { return 1.0; } double result = 2.0 * (gain / (hy + hx)); return result; }
double InformationGainCalculator::calculateInformationGain(const DataFrame& df1, int factorIndex1, const DataFrame& df2, int factorIndex2) { assert(df1.isNominal(factorIndex1)); assert(df2.isNominal(factorIndex2)); double hy = _calculateEntropy(df1, factorIndex1); double hyx = _calculateConditionalEntropy(df1, factorIndex1, df2, factorIndex2); double gain = hy - hyx; return gain; }