You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/FSharp.Stats/Testing/ComparisonMetrics.fs
+39-15Lines changed: 39 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -368,29 +368,28 @@ type ComparisonMetrics = {
368
368
369
369
static membermultiLabelThresholdMap(
370
370
actual:#IConvertible [],
371
-
predictions:(#IConvertible * float []) []
372
-
)=
373
-
374
-
// we have to use a global threshold collection for all binary threshold maps, otherwise we do not necessarily have values for macro/micro averaging for each label.
375
-
letallDistinctThresholds=
371
+
predictions:(#IConvertible * float []) [],
372
+
thresholds:float []
373
+
)=
374
+
// Use global max as prefix so micro/macro averages use a consistent threshold label.
// we have to use a global threshold collection for all binary threshold maps, otherwise we do not necessarily have values for macro/micro averaging for each label.
// With 3 explicit thresholds the result should have 4 entries per label (prefix + 3)
1188
+
testCase "explicit thresholds: result length"(fun _ ->
1189
+
Expect.equal actualExplicit["A"].Length 4"Expected 4 threshold entries for label A with 3 explicit thresholds"
1190
+
)
1191
+
// Values at threshold 0.9 should match the full-threshold result at that threshold
1192
+
testCase "A: explicit threshold 0-9"(fun _ ->
1193
+
TestExtensions.comparisonMetricsEqualRounded 3(snd (actualExplicit["A"][1]))(BinaryConfusionMatrix.create(1,9,0,4)|> ComparisonMetrics.create)"Incorrect A metrics at threshold 0.9"
1194
+
)
1195
+
testCase "B: explicit threshold 0-5"(fun _ ->
1196
+
TestExtensions.comparisonMetricsEqualRounded 3(snd (actualExplicit["B"][2]))(BinaryConfusionMatrix.create(2,10,1,1)|> ComparisonMetrics.create)"Incorrect B metrics at threshold 0.5"
1197
+
)
1198
+
testCase "C: explicit threshold 0-1"(fun _ ->
1199
+
TestExtensions.comparisonMetricsEqualRounded 3(snd (actualExplicit["C"][3]))(BinaryConfusionMatrix.create(6,0,8,0)|> ComparisonMetrics.create)"Incorrect C metrics at threshold 0.1"
1200
+
)
1201
+
testCase "micro-average present"(fun _ ->
1202
+
Expect.isTrue (actualExplicit.ContainsKey("micro-average"))"micro-average key should be present"
1203
+
)
1204
+
testCase "macro-average present"(fun _ ->
1205
+
Expect.isTrue (actualExplicit.ContainsKey("macro-average"))"macro-average key should be present"
0 commit comments