Filtering works on multiple values
This commit is contained in:
parent
0ed06729ba
commit
a00120b1c2
@ -22,7 +22,9 @@ import Data.Conduit.SmartSource
|
|||||||
import Data.Conduit.Header
|
import Data.Conduit.Header
|
||||||
import GEval.Selector
|
import GEval.Selector
|
||||||
|
|
||||||
data Filter = NoFilter | FilterByFeatures (Maybe TabularHeader) String
|
import qualified Data.Set as S
|
||||||
|
|
||||||
|
data Filter = NoFilter | FilterByFeatures (Maybe TabularHeader) (S.Set String)
|
||||||
|
|
||||||
noFilter :: Filter
|
noFilter :: Filter
|
||||||
noFilter = NoFilter
|
noFilter = NoFilter
|
||||||
@ -33,19 +35,19 @@ applyFilter (FilterByFeatures mInHeader featureSpec) tR = applyFeatureFilter mIn
|
|||||||
|
|
||||||
getFilterForScheme :: Maybe TabularHeader -> EvaluationScheme -> Filter
|
getFilterForScheme :: Maybe TabularHeader -> EvaluationScheme -> Filter
|
||||||
getFilterForScheme mTabHeader (EvaluationScheme _ ops) = case findFilter ops of
|
getFilterForScheme mTabHeader (EvaluationScheme _ ops) = case findFilter ops of
|
||||||
Nothing -> NoFilter
|
[] -> NoFilter
|
||||||
Just f -> FilterByFeatures mTabHeader (unpack $ fixIndex f)
|
fs -> FilterByFeatures mTabHeader (S.fromList $ Prelude.map (unpack . fixIndex) fs)
|
||||||
|
|
||||||
fixIndex = replace "[" "<" . replace "]" ">"
|
fixIndex = replace "[" "<" . replace "]" ">"
|
||||||
|
|
||||||
findFilter :: [PreprocessingOperation] -> Maybe Text
|
findFilter :: [PreprocessingOperation] -> [Text]
|
||||||
findFilter [] = Nothing
|
findFilter [] = []
|
||||||
findFilter ((FeatureFilter f):_) = Just f
|
findFilter ((FeatureFilter f):ops) = (f:(findFilter ops))
|
||||||
findFilter (_:ops) = findFilter ops
|
findFilter (_:ops) = findFilter ops
|
||||||
|
|
||||||
|
|
||||||
applyFeatureFilter :: Maybe TabularHeader -> String -> TargetRecord -> Bool
|
applyFeatureFilter :: Maybe TabularHeader -> S.Set String -> TargetRecord -> Bool
|
||||||
applyFeatureFilter mInHeader featureSpec tR = featureSpec `elem` (Prelude.map show fs)
|
applyFeatureFilter mInHeader featureSpec tR = featureSpec `S.isSubsetOf` (S.fromList $ Prelude.map show fs)
|
||||||
where fs = getFeatures Nothing
|
where fs = getFeatures Nothing
|
||||||
BlackBoxDebuggingOptions {
|
BlackBoxDebuggingOptions {
|
||||||
bbdoMinFrequency = 0,
|
bbdoMinFrequency = 0,
|
||||||
|
@ -137,6 +137,8 @@ main = hspec $ do
|
|||||||
runGEvalTest "accuracy-on-sorted" `shouldReturnAlmost` 0.75
|
runGEvalTest "accuracy-on-sorted" `shouldReturnAlmost` 0.75
|
||||||
it "with filtering" $
|
it "with filtering" $
|
||||||
runGEvalTest "accuracy-filtering" `shouldReturnAlmost` 0.6666
|
runGEvalTest "accuracy-filtering" `shouldReturnAlmost` 0.6666
|
||||||
|
it "with filtering 2" $
|
||||||
|
runGEvalTest "accuracy-multiple-filtering" `shouldReturnAlmost` 0.5
|
||||||
describe "F-measure" $ do
|
describe "F-measure" $ do
|
||||||
it "simple example" $
|
it "simple example" $
|
||||||
runGEvalTest "f-measure-simple" `shouldReturnAlmost` 0.57142857
|
runGEvalTest "f-measure-simple" `shouldReturnAlmost` 0.57142857
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
foo
|
||||||
|
bar
|
||||||
|
bar
|
||||||
|
foo
|
||||||
|
foo
|
||||||
|
foo
|
||||||
|
foo
|
||||||
|
bar
|
|
@ -0,0 +1 @@
|
|||||||
|
--metric Accuracy:f<in[1]:en>N<xyz>f<in[1]:general>
|
@ -0,0 +1,8 @@
|
|||||||
|
foo
|
||||||
|
bar
|
||||||
|
foo
|
||||||
|
foo
|
||||||
|
foo
|
||||||
|
foo
|
||||||
|
foo
|
||||||
|
bar
|
|
@ -0,0 +1,8 @@
|
|||||||
|
general
|
||||||
|
de specific
|
||||||
|
general en
|
||||||
|
|
||||||
|
general
|
||||||
|
general
|
||||||
|
en specific
|
||||||
|
en general
|
|
Loading…
Reference in New Issue
Block a user