From 17d6bfd93c388929518589051dde30c6007f3b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Fuch=C3=9F?= Date: Thu, 22 Aug 2024 16:16:11 +0200 Subject: [PATCH] Update names of TP/.. --- .../ClassificationMetricsCalculatorImpl.kt | 18 +++++++++--------- .../result/SingleClassificationResult.kt | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/calculator/src/main/kotlin/edu/kit/kastel/mcse/ardoco/metrics/internal/ClassificationMetricsCalculatorImpl.kt b/calculator/src/main/kotlin/edu/kit/kastel/mcse/ardoco/metrics/internal/ClassificationMetricsCalculatorImpl.kt index f1b1270..97e8d06 100644 --- a/calculator/src/main/kotlin/edu/kit/kastel/mcse/ardoco/metrics/internal/ClassificationMetricsCalculatorImpl.kt +++ b/calculator/src/main/kotlin/edu/kit/kastel/mcse/ardoco/metrics/internal/ClassificationMetricsCalculatorImpl.kt @@ -83,7 +83,7 @@ internal class ClassificationMetricsCalculatorImpl : ClassificationMetricsCalcul ): List { 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) @@ -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!! } } @@ -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" } @@ -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, diff --git a/calculator/src/main/kotlin/edu/kit/kastel/mcse/ardoco/metrics/result/SingleClassificationResult.kt b/calculator/src/main/kotlin/edu/kit/kastel/mcse/ardoco/metrics/result/SingleClassificationResult.kt index f34e2dc..5f46086 100644 --- a/calculator/src/main/kotlin/edu/kit/kastel/mcse/ardoco/metrics/result/SingleClassificationResult.kt +++ b/calculator/src/main/kotlin/edu/kit/kastel/mcse/ardoco/metrics/result/SingleClassificationResult.kt @@ -8,13 +8,13 @@ import edu.kit.kastel.mcse.ardoco.metrics.result.ClassificationResult.Companion. */ data class SingleClassificationResult( /** The true positives */ - val tp: Set, + val truePositives: Set, /** The false positives */ - val fp: Set, + val falsePositives: Set, /** The false negatives */ - val fn: Set, + val falseNegatives: Set, /** 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, @@ -26,10 +26,10 @@ data class SingleClassificationResult( 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() } }