handle Accuracy

This commit is contained in:
Filip Gralinski 2015-10-31 19:05:23 +01:00 committed by Filip Gralinski
parent e55708a8f0
commit cf6f287763
8 changed files with 24 additions and 4 deletions

View File

@ -173,6 +173,6 @@ Then let Gonito pull them and evaluate your results.
evaluated (default: "out.tsv")
--expected-file EXPECTED The name of the file with expected
results (default: "expected.tsv")
--metric METRIC Metric to be used - RMSE, MSE or BLEU (default: RMSE)
--metric METRIC Metric to be used - RMSE, MSE, Accuracy or BLEU (default: RMSE)
If you need another metric, let me know, or do it yourself!

View File

@ -1,5 +1,5 @@
name: geval
version: 0.1.1.1
version: 0.1.2.1
synopsis: Machine learning evaluation tools
description: Please see README.md
homepage: http://github.com/name/project

View File

@ -38,7 +38,7 @@ import GEval.BLEU
type MetricValue = Double
data Metric = RMSE | MSE | BLEU
data Metric = RMSE | MSE | BLEU | Accuracy
deriving (Show, Read)
defaultOutDirectory = "."
@ -141,6 +141,9 @@ gevalCore' BLEU = gevalCore'' (Prelude.map Prelude.words . DLS.splitOn "\t" . un
| c >= r = 1.0
| otherwise = exp (1.0 - (r /. c))
gevalCore' Accuracy = gevalCore'' strip strip hitOrMiss averageC id
where hitOrMiss (x,y) = if x == y then 1.0 else 0.0
(/.) :: Int -> Int -> Double
x /. 0 = 1.0
x /. y = (fromIntegral x) / (fromIntegral y)

View File

@ -73,7 +73,7 @@ metricReader = option auto
<> value defaultMetric
<> showDefault
<> metavar "METRIC"
<> help "Metric to be used - RMSE, MSE or BLEU" )
<> help "Metric to be used - RMSE, MSE, Accuracy or BLEU" )
runGEval :: [String] -> IO (Either (ParserResult GEvalOptions) (Maybe MetricValue))
runGEval args = do

View File

@ -33,6 +33,12 @@ main = hspec $ do
"test/bleu-perfect/bleu-perfect",
"--out-directory",
"test/bleu-perfect/bleu-perfect-solution"]) >>= extractVal) `shouldReturnAlmost` 1.0000
describe "Accuracy" $ do
it "simple example" $ do
((runGEval ["--expected-directory",
"test/accuracy-simple/accuracy-simple",
"--out-directory",
"test/accuracy-simple/accuracy-simple-solution"]) >>= extractVal) `shouldReturnAlmost` 0.6
describe "precision count" $ do
it "simple test" $ do
precisionCount [["Alice", "has", "a", "cat" ]] ["Ala", "has", "cat"] `shouldBe` 2

View File

@ -0,0 +1,5 @@
A
B
A
B
B
1 A
2 B
3 A
4 B
5 B

View File

@ -0,0 +1 @@
--metric Accuracy

View File

@ -0,0 +1,5 @@
A
B
B
A
B
1 A
2 B
3 B
4 A
5 B