modified to show frequency of frequent items

This commit is contained in:
IGI-111
2015-04-02 08:38:59 +02:00
parent ffd45a82bc
commit 51d1cfc463

View File

@@ -48,8 +48,8 @@ parseCSV :: String -> Either ParseError [ItemSet]
parseCSV input = parse csvFile ("unknown") input parseCSV input = parse csvFile ("unknown") input
-- frequent items -- frequent items
frequentItems :: [ItemSet] -> Support -> [(Item, Integer)] frequentItems :: Integral a => [ItemSet] -> Support -> Map Item a
frequentItems x y = Set.toList $ Map.keysSet pi frequency where frequentItems x y = pi where
pi = Map.filter (>= frequency) m where pi = Map.filter (>= frequency) m where
frequency = ceiling(y * (fromIntegral $ length x)) where frequency = ceiling(y * (fromIntegral $ length x)) where
m = foldl count Map.empty x where m = foldl count Map.empty x where
@@ -70,7 +70,7 @@ main = do
print e print e
Right r -> do Right r -> do
let i = frequentItems r (read s) let i = frequentItems r (read s)
mapM_ print $ i print $ i
-- helper functions defined here -- helper functions defined here