From f7698e2ac0b5a48bf6f0bdf442b78f4a83f23342 Mon Sep 17 00:00:00 2001 From: phpfs Date: Wed, 5 May 2021 09:16:33 +0200 Subject: [PATCH] Fix calculation of total count --- app/src/pages/BinaryMetricsPage/BinaryMetricsPage.tsx | 6 +++--- app/src/utils/numberOfDistinctPairs.ts | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 app/src/utils/numberOfDistinctPairs.ts diff --git a/app/src/pages/BinaryMetricsPage/BinaryMetricsPage.tsx b/app/src/pages/BinaryMetricsPage/BinaryMetricsPage.tsx index 01f4444b..28dbf9a0 100644 --- a/app/src/pages/BinaryMetricsPage/BinaryMetricsPage.tsx +++ b/app/src/pages/BinaryMetricsPage/BinaryMetricsPage.tsx @@ -25,6 +25,7 @@ import { Store } from 'store/models'; import { MetricsTuplesCategories } from 'types/MetricsTuplesCategories'; import { TuplesLoader } from 'types/TuplesLoader'; import { intersectionDescription } from 'utils/intersectionDescription'; +import { numberOfDistinctPairs } from 'utils/numberOfDistinctPairs'; const getCountsByTuplesCategory = ( store: Store, @@ -118,9 +119,8 @@ const mapStateToProps = (state: Store): BinaryMetricsPageStateProps => ({ state.BinaryMetricsStore.selectedDataView ), confusionMatrix: { - totalCount: Math.pow( - state.BenchmarkConfigurationStore.selectedDataset?.numberOfRecords ?? 0, - 2 + totalCount: numberOfDistinctPairs( + state.BenchmarkConfigurationStore.selectedDataset?.numberOfRecords ?? 0 ), falseNegatives: getPairCountByTuplesCategory( state, diff --git a/app/src/utils/numberOfDistinctPairs.ts b/app/src/utils/numberOfDistinctPairs.ts new file mode 100644 index 00000000..2c0ccdf6 --- /dev/null +++ b/app/src/utils/numberOfDistinctPairs.ts @@ -0,0 +1,2 @@ +export const numberOfDistinctPairs = (size: number): number => + (size * (size - 1)) / 2;