From 872724722a4cb29ecbbdd9d16e5fa82addc31161 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Tue, 12 Feb 2019 08:36:52 +0100 Subject: [PATCH 1/3] Fix SMAPE on zero values --- geval.cabal | 2 +- src/GEval/Core.hs | 2 +- test/Spec.hs | 2 +- test/smape-simple/smape-simple-solution/test-A/out.tsv | 1 + test/smape-simple/smape-simple/test-A/expected.tsv | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/geval.cabal b/geval.cabal index 92f2910..515655e 100644 --- a/geval.cabal +++ b/geval.cabal @@ -1,5 +1,5 @@ name: geval -version: 1.15.0.0 +version: 1.15.0.1 synopsis: Machine learning evaluation tools description: Please see README.md homepage: http://github.com/name/project diff --git a/src/GEval/Core.hs b/src/GEval/Core.hs index 9fc0a55..c675bd0 100644 --- a/src/GEval/Core.hs +++ b/src/GEval/Core.hs @@ -559,7 +559,7 @@ gevalCore' MAE _ = gevalCoreWithoutInput outParser outParser itemAbsoluteError a gevalCore' SMAPE _ = gevalCoreWithoutInput outParser outParser smape averageC (* 100.0) where outParser = getValue . TR.double - smape (exp, out) = (abs (exp-out)) / ((abs exp) + (abs out)) + smape (exp, out) = (abs (exp-out)) `safeDoubleDiv` ((abs exp) + (abs out)) gevalCore' Pearson _ = gevalCoreByCorrelationMeasure pearson gevalCore' Spearman _ = gevalCoreByCorrelationMeasure spearman diff --git a/test/Spec.hs b/test/Spec.hs index 051013a..f3d7429 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -86,7 +86,7 @@ main = hspec $ do runGEvalTest "mae-simple" `shouldReturnAlmost` 1.5 describe "SMAPE" $ do it "simple test" $ - runGEvalTest "smape-simple" `shouldReturnAlmost` 54.2222222222222222 + runGEvalTest "smape-simple" `shouldReturnAlmost` 45.1851851851852 describe "Spearman's rank correlation coefficient" $ do it "simple test" $ do runGEvalTest "spearman-simple" `shouldReturnAlmost` (- 0.5735) diff --git a/test/smape-simple/smape-simple-solution/test-A/out.tsv b/test/smape-simple/smape-simple-solution/test-A/out.tsv index 14fce23..9c8e935 100644 --- a/test/smape-simple/smape-simple-solution/test-A/out.tsv +++ b/test/smape-simple/smape-simple-solution/test-A/out.tsv @@ -3,3 +3,4 @@ -2.5 3 0.3 +0.0 diff --git a/test/smape-simple/smape-simple/test-A/expected.tsv b/test/smape-simple/smape-simple/test-A/expected.tsv index f6cf468..8e97c1e 100644 --- a/test/smape-simple/smape-simple/test-A/expected.tsv +++ b/test/smape-simple/smape-simple/test-A/expected.tsv @@ -3,3 +3,4 @@ 0.0 3 1.2 +0.0 From 85fdd8014df6ec6398b9c7d890cff8b1db0cd32c Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Tue, 12 Feb 2019 09:44:20 +0100 Subject: [PATCH 2/3] Minor fixes in README --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1ba1745..57dc20f 100644 --- a/README.md +++ b/README.md @@ -40,25 +40,25 @@ order to run `geval` you need to either add `$HOME/.local/bin` to If you see a message like this: - Configuring lzma-0.0.0.3... - clang: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument] - Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2: Missing dependency on a foreign - library: - * Missing (or bad) header file: lzma.h - This problem can usually be solved by installing the system package that - provides this library (you may need the "-dev" version). If the library is - already installed but in a non-standard location then you can use the flags - --extra-include-dirs= and --extra-lib-dirs= to specify where it is. - If the header file does exist, it may contain errors that are caught by the C - compiler at the preprocessing stage. In this case you can re-run configure - with the verbosity flag -v3 to see the error messages. + Configuring lzma-0.0.0.3... + clang: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument] + Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2: Missing dependency on a foreign + library: + * Missing (or bad) header file: lzma.h + This problem can usually be solved by installing the system package that + provides this library (you may need the "-dev" version). If the library is + already installed but in a non-standard location then you can use the flags + --extra-include-dirs= and --extra-lib-dirs= to specify where it is. + If the header file does exist, it may contain errors that are caught by the C + compiler at the preprocessing stage. In this case you can re-run configure + with the verbosity flag -v3 to see the error messages. -It means that you need to install lzma library on your operating +it means that you need to install lzma library on your operating system. The same might go for pkg-config. On macOS (it's more likely to happen on macOS, as these packages are usually installed out of box on Linux), you need to run: - brew install xz - brew install pkg-config + brew install xz + brew install pkg-config ### Plan B — just download the GEval binary From 9bfcb3bbdea2d77fd3e6f1027ce5bb0d372d7ba8 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Tue, 12 Feb 2019 09:57:43 +0100 Subject: [PATCH 3/3] Alternative binary described in README --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 57dc20f..80c15d9 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,13 @@ to happen on macOS, as these packages are usually installed out of box on Linux) chmod u+x geval ./geval --help +If this binary does not work on your Linux (likely to happen on Arch Linux), try another one: + + wget https://gonito.net/get/bin/geval-alt + mv geval-alt geval + chmod u+x geval + ./geval --help + ## Quick tour Let's use GEval to evaluate machine translation (MT) systems (but keep