Soft2D-F... Metric is inclusive now.

This commit is contained in:
Filip Graliński 2019-09-03 17:19:05 +02:00
parent 5f9d2b85c7
commit 029e3880f7
6 changed files with 22 additions and 5 deletions

View File

@ -104,11 +104,13 @@ rectangleParser = do
x1 <- decimal
char ','
y1 <- decimal
return $ Rectangle (Point x0 y0) (Point x1 y1)
if x1 < x0 || y1 < y0
then fail "wrong coordinates"
else return $ Rectangle (Point x0 y0) (Point x1 y1)
rectangleArea :: Rectangle -> Integer
rectangleArea (Rectangle (Point x0 y0) (Point x1 y1)) =
(fromIntegral $ x1 - x0) * (fromIntegral $ y1 - y0)
(fromIntegral $ x1 - x0 + 1) * (fromIntegral $ y1 - y0 + 1)
clippingArea :: LabeledClipping -> Integer
clippingArea (LabeledClipping _ (Clipping _ rect)) = rectangleArea rect

View File

@ -121,8 +121,8 @@ expectedScore (EvaluationScheme (SoftFMeasure beta) [])
recall = 0.75
in weightedHarmonicMean beta precision recall
expectedScore (EvaluationScheme (Soft2DFMeasure beta) [])
= let precision = 0.21117747440273
recall = 0.27423822714681
= let precision = 0.211622914314256
recall = 0.2749908502976
in (weightedHarmonicMean beta precision recall) / 2.0
listOfAvailableEvaluationSchemes :: [EvaluationScheme]

View File

@ -276,7 +276,9 @@ main = hspec $ do
runGEvalTest "probabilistic-soft-f1-calibrated" `shouldReturnAlmost` 0.88888888888
describe "Soft2D-F1" $ do
it "simple test" $ do
runGEvalTest "soft2d-f1-simple" `shouldReturnAlmost` 0.218457349437945
runGEvalTest "soft2d-f1-simple" `shouldReturnAlmost` 0.22053934201995676
it "very narrow rectangles" $ do
runGEvalTest "soft2d-f1-one-pixel" `shouldReturnAlmost` 0.281992045358382
describe "test edit-distance library" $ do
it "for handling UTF8" $ do
levenshteinDistance defaultEditCosts "źdźbło" "źd好bło" `shouldBe` 1

View File

@ -0,0 +1,6 @@
3/100,200,100,200
3/100,200,101,200
3/100,200,100,200
3/100,200,102,202
2/1000,2000,1000,2000 1/1000,2000,1000,2000
1/100,150,300,350
1 3/100,200,100,200
2 3/100,200,101,200
3 3/100,200,100,200
4 3/100,200,102,202
5 2/1000,2000,1000,2000 1/1000,2000,1000,2000
6 1/100,150,300,350

View File

@ -0,0 +1 @@
--metric Soft2D-F1

View File

@ -0,0 +1,6 @@
3/100,200,100,400
3/100,200,101,201
3/100,200,101,201
3/100,200,101,201
3/1000,2000,1000,2000 4/1000,2000,1000,2000
2/100,150,300,350
1 3/100,200,100,400
2 3/100,200,101,201
3 3/100,200,101,201
4 3/100,200,101,201
5 3/1000,2000,1000,2000 4/1000,2000,1000,2000
6 2/100,150,300,350