Skip to content

Commit

Permalink
Update names of TP/..
Browse files Browse the repository at this point in the history
  • Loading branch information
dfuchss committed Aug 22, 2024
1 parent 5b68073 commit 17d6bfd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ internal class ClassificationMetricsCalculatorImpl : ClassificationMetricsCalcul
): List<AggregatedClassificationResult> {
val macroAverage = calculateMacroAverage(singleClassificationResults)

val weightsForAverage = weights ?: singleClassificationResults.map { it.tp.size + it.fn.size }
val weightsForAverage = weights ?: singleClassificationResults.map { it.truePositives.size + it.falseNegatives.size }
val weightedAverage = calculateWeightedAverage(singleClassificationResults, weightsForAverage, AggregationType.WEIGHTED_AVERAGE)

val microAverage = calculateMicroAverage(singleClassificationResults)
Expand All @@ -96,21 +96,21 @@ internal class ClassificationMetricsCalculatorImpl : ClassificationMetricsCalcul

require(
singleClassificationResults.all {
(singleClassificationResults[0].tn == null) == (it.tn == null)
(singleClassificationResults[0].trueNegatives == null) == (it.trueNegatives == null)
}
) { "All classificationResults must have either all or no tn" }

var tp = 0
var fp = 0
var fn = 0
var tn: Int? = if (singleClassificationResults[0].tn != null) 0 else null
var tn: Int? = if (singleClassificationResults[0].trueNegatives != null) 0 else null

for (classificationResult in singleClassificationResults) {
tp += classificationResult.tp.size
fp += classificationResult.fp.size
fn += classificationResult.fn.size
tp += classificationResult.truePositives.size
fp += classificationResult.falsePositives.size
fn += classificationResult.falseNegatives.size
if (tn != null) {
tn += classificationResult.tn!!
tn += classificationResult.trueNegatives!!
}
}

Expand All @@ -131,7 +131,7 @@ internal class ClassificationMetricsCalculatorImpl : ClassificationMetricsCalcul

require(
singleClassificationResults.all {
(singleClassificationResults[0].tn == null) == (it.tn == null)
(singleClassificationResults[0].trueNegatives == null) == (it.trueNegatives == null)
}
) { "All classificationResults must have either all or no tn" }

Expand Down Expand Up @@ -168,7 +168,7 @@ internal class ClassificationMetricsCalculatorImpl : ClassificationMetricsCalcul
phiCoefficientMax /= sumOfWeights
phiOverPhiMax /= sumOfWeights

return if (singleClassificationResults[0].tn == null) {
return if (singleClassificationResults[0].trueNegatives == null) {
AggregatedClassificationResult(
type,
precision,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import edu.kit.kastel.mcse.ardoco.metrics.result.ClassificationResult.Companion.
*/
data class SingleClassificationResult<T>(
/** The true positives */
val tp: Set<T>,
val truePositives: Set<T>,
/** The false positives */
val fp: Set<T>,
val falsePositives: Set<T>,
/** The false negatives */
val fn: Set<T>,
val falseNegatives: Set<T>,
/** The true negatives. If not available, this is null. */
val tn: Int?,
val trueNegatives: Int?,
override val precision: Double,
override val recall: Double,
override val f1: Double,
Expand All @@ -26,10 +26,10 @@ data class SingleClassificationResult<T>(
override val phiOverPhiMax: Double?
) : ClassificationResult {
override fun prettyPrint() {
logger.info("True Positives: ${tp.size}")
logger.info("False Positives: ${fp.size}")
logger.info("False Negatives: ${fn.size}")
logger.info("True Negatives: ${tn ?: "N/A"}")
logger.info("True Positives: ${truePositives.size}")
logger.info("False Positives: ${falsePositives.size}")
logger.info("False Negatives: ${falseNegatives.size}")
logger.info("True Negatives: ${trueNegatives ?: "N/A"}")
super.prettyPrint()
}
}

0 comments on commit 17d6bfd

Please sign in to comment.