private fun buildSmallContingencyTables(): SmallContingencyTables? { val allLabelSet: MutableSet<String> = TreeSet() for (outcome in id2Outcome.getOutcomes()) { allLabelSet.addAll(outcome.getLabels()) } val labelList: List<String> = ArrayList(allLabelSet) val numberOfLabels = labelList.size val counterIncreaseValue = 1.0 val smallContingencyTables = SmallContingencyTables(labelList) for (allLabelsClassId in 0 until numberOfLabels) { for (outcome in id2Outcome.getOutcomes()) { val localClassId: Int = outcome.getReverseLabelMapping(labelList).get(allLabelsClassId) val threshold: Double = outcome.getBipartitionThreshold() var goldValue: Double var predictionValue: Double if (localClassId == -1) { goldValue = 0.0 predictionValue = 0.0 } else { goldValue = outcome.getGoldstandard().get(localClassId) predictionValue = outcome.getPrediction().get(localClassId) } if (goldValue >= threshold) { if (predictionValue >= threshold) { smallContingencyTables.addTruePositives( allLabelsClassId, counterIncreaseValue ) } else { smallContingencyTables.addFalseNegatives( allLabelsClassId, counterIncreaseValue ) } } else { if (predictionValue >= threshold) { smallContingencyTables.addFalsePositives( allLabelsClassId, counterIncreaseValue ) } else { smallContingencyTables.addTrueNegatives( allLabelsClassId, counterIncreaseValue ) } } } } return smallContingencyTables }
build small contingency tables ( a small contingency table for each label ) from id2Outcome