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 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 = NoFilter
|
||||
@ -33,19 +35,19 @@ applyFilter (FilterByFeatures mInHeader featureSpec) tR = applyFeatureFilter mIn
|
||||
|
||||
getFilterForScheme :: Maybe TabularHeader -> EvaluationScheme -> Filter
|
||||
getFilterForScheme mTabHeader (EvaluationScheme _ ops) = case findFilter ops of
|
||||
Nothing -> NoFilter
|
||||
Just f -> FilterByFeatures mTabHeader (unpack $ fixIndex f)
|
||||
[] -> NoFilter
|
||||
fs -> FilterByFeatures mTabHeader (S.fromList $ Prelude.map (unpack . fixIndex) fs)
|
||||
|
||||
fixIndex = replace "[" "<" . replace "]" ">"
|
||||
|
||||
findFilter :: [PreprocessingOperation] -> Maybe Text
|
||||
findFilter [] = Nothing
|
||||
findFilter ((FeatureFilter f):_) = Just f
|
||||
findFilter :: [PreprocessingOperation] -> [Text]
|
||||
findFilter [] = []
|
||||
findFilter ((FeatureFilter f):ops) = (f:(findFilter ops))
|
||||
findFilter (_:ops) = findFilter ops
|
||||
|
||||
|
||||
applyFeatureFilter :: Maybe TabularHeader -> String -> TargetRecord -> Bool
|
||||
applyFeatureFilter mInHeader featureSpec tR = featureSpec `elem` (Prelude.map show fs)
|
||||
applyFeatureFilter :: Maybe TabularHeader -> S.Set String -> TargetRecord -> Bool
|
||||
applyFeatureFilter mInHeader featureSpec tR = featureSpec `S.isSubsetOf` (S.fromList $ Prelude.map show fs)
|
||||
where fs = getFeatures Nothing
|
||||
BlackBoxDebuggingOptions {
|
||||
bbdoMinFrequency = 0,
|
||||
|
@ -137,6 +137,8 @@ main = hspec $ do
|
||||
runGEvalTest "accuracy-on-sorted" `shouldReturnAlmost` 0.75
|
||||
it "with filtering" $
|
||||
runGEvalTest "accuracy-filtering" `shouldReturnAlmost` 0.6666
|
||||
it "with filtering 2" $
|
||||
runGEvalTest "accuracy-multiple-filtering" `shouldReturnAlmost` 0.5
|
||||
describe "F-measure" $ do
|
||||
it "simple example" $
|
||||
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