modified to show frequency of frequent items
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user