Class ConfusionMatrixMetric
java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_eval.evaluator.metric.Metric<ConfusionMatrix>
de.uni_mannheim.informatik.dws.melt.matching_eval.evaluator.metric.cm.ConfusionMatrixMetric
Confusion Matrix Metric.
Can handle full and partial gold standards as well as explict null mappings (there is no match for one entity).
- Author:
- Sven Hertling, Jan Portisch
- See Also:
-
- https://github.com/DanFaria/OAEI_SealsClient/blob/020d97bbfb6816dcca55de5ce178c716da15b711/SealsClientSource/src/main/java/eu/sealsproject/omt/client/Client.java#L322
- https://github.com/DanFaria/OAEI_SealsClient/blob/master/SealsClientSource/src/main/java/eu/sealsproject/omt/client/HashAlignment.java
- http://www.cs.ox.ac.uk/isg/projects/SEALS/oaei/2017/oaei2017_umls_reference.html
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ConfusionMatrix
calculateConfusionMatrixFromMappings
(Alignment truePositives, Alignment falsePositives, Alignment falseNegatives, int numberOfCorrespondences) Calculation method which calculates the confusion matrix given three mappings: tp, fp, and fn.compute
(ExecutionResult executionResult) compute
(Alignment referenceAlignment, Alignment systemAlignment, GoldStandardCompleteness gsCompleteness) compute
(Alignment referenceAlignment, Alignment systemAlignment, GoldStandardCompleteness gsCompleteness, Alignment evaluationExclusionAlignment) private ConfusionMatrix
computeForCompleteGoldStandard
(Alignment referenceAlignment, Alignment systemAlignment) Calculate the confusion matrix under the premises that the gold standard is complete.private ConfusionMatrix
computeForPartialGoldStandard
(Alignment referenceAlignment, Alignment systemAlignment, GoldStandardCompleteness gsCompleteness) Calculate the confusion matrix under the premises that the gold standard is incomplete, i.e., partial.private static double
divideWithTwoDenominators
(double numerator, double denominatorOne, double denominatorTwo) Simple division that is to be performed.private ConfusionMatrix
executeAggregation
(Iterable<ConfusionMatrix> confusionMatrices, ConfusionMatrixAggregationMode aggregationMode) Internal aggregation logic.getMacroAverages
(Iterable<ConfusionMatrix> confusionMatrices) Returns aggregated confusion matrices according to the macro average.getMacroAveragesForResults
(Iterable<ExecutionResult> resultsForCalculation) Returns aggregated confusion matrices according to the macro average.getMacroAveragesForResults
(Iterable<ExecutionResult> resultsForCalculation, int numberOfTestCases) Returns aggregated confusion matrices according to the macro average.getMicroAverages
(Iterable<ConfusionMatrix> confusionMatrices) Returns aggregated confusion matrices according to the micro average.getMicroAveragesForResults
(Iterable<ExecutionResult> resultsForCalculation) Returns aggregated confusion matrices according to the micro average.
-
Field Details
-
LOGGER
private org.slf4j.Logger LOGGERDefault Logger
-
-
Constructor Details
-
ConfusionMatrixMetric
public ConfusionMatrixMetric()
-
-
Method Details
-
compute
- Specified by:
compute
in classMetric<ConfusionMatrix>
-
compute
public ConfusionMatrix compute(Alignment referenceAlignment, Alignment systemAlignment, GoldStandardCompleteness gsCompleteness, Alignment evaluationExclusionAlignment) -
compute
public ConfusionMatrix compute(Alignment referenceAlignment, Alignment systemAlignment, GoldStandardCompleteness gsCompleteness) -
computeForPartialGoldStandard
private ConfusionMatrix computeForPartialGoldStandard(Alignment referenceAlignment, Alignment systemAlignment, GoldStandardCompleteness gsCompleteness) Calculate the confusion matrix under the premises that the gold standard is incomplete, i.e., partial.- Parameters:
referenceAlignment
- reference alignmentsystemAlignment
- system alignmentgsCompleteness
- gold standard completeness- Returns:
- The confusion matrix.
-
computeForCompleteGoldStandard
private ConfusionMatrix computeForCompleteGoldStandard(Alignment referenceAlignment, Alignment systemAlignment) Calculate the confusion matrix under the premises that the gold standard is complete.- Parameters:
referenceAlignment
- reference alignmentsystemAlignment
- system alignment- Returns:
- The confusion matrix.
-
calculateConfusionMatrixFromMappings
public static ConfusionMatrix calculateConfusionMatrixFromMappings(Alignment truePositives, Alignment falsePositives, Alignment falseNegatives, int numberOfCorrespondences) Calculation method which calculates the confusion matrix given three mappings: tp, fp, and fn.- Parameters:
truePositives
- True Positive (tp) mapping.falsePositives
- False Positive (fp) mapping.falseNegatives
- False Negative (fn) mapping.numberOfCorrespondences
- The number of correspondences.- Returns:
- The confusion matrix.
-
getMicroAveragesForResults
Returns aggregated confusion matrices according to the micro average. The micro average sums up individual true positives, false positives and false negatives and calculates one confusion matrix.- Parameters:
resultsForCalculation
- The results for which an aggregated confusion matrix shall be computed.- Returns:
- Aggregated Confusion Matrices
-
getMacroAveragesForResults
Returns aggregated confusion matrices according to the macro average.- Parameters:
resultsForCalculation
- The results for which an aggregated confusion matrix shall be computed.- Returns:
- Aggregated Confusion Matrices Aggregated Confusion Matrices
-
getMacroAveragesForResults
public ConfusionMatrix getMacroAveragesForResults(Iterable<ExecutionResult> resultsForCalculation, int numberOfTestCases) Returns aggregated confusion matrices according to the macro average.- Parameters:
resultsForCalculation
- The results for which an aggregated confusion matrix shall be computed.numberOfTestCases
- The number of testcases which should be used for the calculation- Returns:
- Aggregated Confusion Matrices Aggregated Confusion Matrices
-
getMicroAverages
Returns aggregated confusion matrices according to the micro average. The micro average sums up individual true positives, false positives and false negatives and calculates one confusion matrix.- Parameters:
confusionMatrices
- The confusion matrices for which an aggregated confusion matrix shall be computed.- Returns:
- Aggregated Confusion Matrices
-
getMacroAverages
Returns aggregated confusion matrices according to the macro average.- Parameters:
confusionMatrices
- The confusion matrices for which an aggregated confusion matrix shall be computed.- Returns:
- Aggregated Confusion Matrices Aggregated Confusion Matrices
-
executeAggregation
private ConfusionMatrix executeAggregation(Iterable<ConfusionMatrix> confusionMatrices, ConfusionMatrixAggregationMode aggregationMode) Internal aggregation logic.- Parameters:
confusionMatrices
- ConfusionMatrices that shall be used for the aggregation.aggregationMode
- The kind of aggregation that is to be performed.- Returns:
- Resulting confusion matrix.
-
divideWithTwoDenominators
private static double divideWithTwoDenominators(double numerator, double denominatorOne, double denominatorTwo) Simple division that is to be performed. The two denominators will be added.- Parameters:
numerator
- Numerator of fractiondenominatorOne
- Denominator 1denominatorTwo
- Denominator 2- Returns:
- Result as double.
-