handle Accuracy
This commit is contained in:
parent
e55708a8f0
commit
cf6f287763
@ -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!
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -0,0 +1,5 @@
|
||||
A
|
||||
B
|
||||
A
|
||||
B
|
||||
B
|
|
1
test/accuracy-simple/accuracy-simple/config.txt
Normal file
1
test/accuracy-simple/accuracy-simple/config.txt
Normal file
@ -0,0 +1 @@
|
||||
--metric Accuracy
|
5
test/accuracy-simple/accuracy-simple/test-A/expected.tsv
Normal file
5
test/accuracy-simple/accuracy-simple/test-A/expected.tsv
Normal file
@ -0,0 +1,5 @@
|
||||
A
|
||||
B
|
||||
B
|
||||
A
|
||||
B
|
|
Loading…
Reference in New Issue
Block a user