add --alt-metric option
This commit is contained in:
parent
4768931221
commit
d370e375a0
@ -100,9 +100,13 @@ specParser = GEvalSpecification
|
||||
<> showDefault
|
||||
<> metavar "INPUT"
|
||||
<> help "The name of the file with the input (applicable only for some metrics)" )
|
||||
<*> metricReader
|
||||
<*> ((flip fromMaybe) <$> altMetricReader <*> metricReader)
|
||||
<*> optional precisionArgParser
|
||||
|
||||
sel :: Maybe Metric -> Metric -> Metric
|
||||
sel Nothing m = m
|
||||
sel (Just m) _ = m
|
||||
|
||||
metricReader :: Parser Metric
|
||||
metricReader = option auto
|
||||
( long "metric"
|
||||
@ -112,6 +116,13 @@ metricReader = option auto
|
||||
<> metavar "METRIC"
|
||||
<> help "Metric to be used - RMSE, MSE, Accuracy, LogLoss, Likelihood, F-measure (specify as F1, F2, F0.25, etc.), MAP, BLEU, NMI, ClippEU, LogLossHashed, LikelihoodHashed, BIO-F1, BIO-F1-Labels or CharMatch" )
|
||||
|
||||
altMetricReader :: Parser (Maybe Metric)
|
||||
altMetricReader = optional $ option auto
|
||||
( long "alt-metric"
|
||||
<> short 'a'
|
||||
<> metavar "METRIC"
|
||||
<> help "Alternative metric (overrides --metric option)" )
|
||||
|
||||
runGEval :: [String] -> IO (Either (ParserResult GEvalOptions) (Maybe MetricValue))
|
||||
runGEval args = do
|
||||
ret <- runGEvalGetOptions args
|
||||
|
@ -290,6 +290,9 @@ main = hspec $ do
|
||||
it "test sorting" $ do
|
||||
results <- runLineByLineGeneralized FirstTheWorst sampleChallenge Data.Conduit.List.consume
|
||||
Prelude.head (Prelude.map (\(LineRecord inp _ _ _ _) -> inp) results) `shouldBe` "baq"
|
||||
describe "handle --alt-metric option" $ do
|
||||
it "accuracy instead of likelihood" $ do
|
||||
runGEvalTestExtraOptions ["--alt-metric", "Accuracy"] "likelihood-simple" `shouldReturnAlmost` 0.75
|
||||
|
||||
|
||||
neverMatch :: Char -> Int -> Bool
|
||||
@ -309,11 +312,13 @@ testMatchFun _ _ = False
|
||||
extractVal :: (Either (ParserResult GEvalOptions) (Maybe MetricValue)) -> IO MetricValue
|
||||
extractVal (Right (Just val)) = return val
|
||||
|
||||
runGEvalTest testName = (runGEval [
|
||||
runGEvalTest = runGEvalTestExtraOptions []
|
||||
|
||||
runGEvalTestExtraOptions extraOptions testName = (runGEval ([
|
||||
"--expected-directory",
|
||||
"test/" ++ testName ++ "/" ++ testName,
|
||||
"--out-directory",
|
||||
"test/" ++ testName ++ "/" ++ testName ++ "-solution"]) >>= extractVal
|
||||
"test/" ++ testName ++ "/" ++ testName ++ "-solution"] ++ extraOptions)) >>= extractVal
|
||||
|
||||
extractMetric :: String -> IO (Maybe Metric)
|
||||
extractMetric testName = do
|
||||
|
Loading…
Reference in New Issue
Block a user