diff --git a/DataModel.hs b/DataModel.hs
index 7ce2e48..fffeb07 100644
--- a/DataModel.hs
+++ b/DataModel.hs
@@ -6,6 +6,7 @@ type Count = Int
type Frequency = Double
type Confidence = Double
+type Lift = Double
class Freq a where
frequency :: [ItemSet] -> a -> Frequency
@@ -50,3 +51,5 @@ instance Freq Rule where
confidence :: [ItemSet] -> Rule -> Confidence
confidence table (Rule x y) = frequency table (Rule x y) / frequency table x
+lift :: [ItemSet] -> Rule -> Lift
+lift table (Rule x y) = confidence table (Rule x y) / frequency table y
diff --git a/phase1.hs b/phase1.hs
index aa56fe7..192dee1 100644
--- a/phase1.hs
+++ b/phase1.hs
@@ -9,7 +9,7 @@ main :: IO()
main = do
args <- getArgs
when (2 > length args)
- (error "Usage: Main
")
+ (error "Usage: Main table.csv threshold [outfile.csv]")
let filename = head args
let threshold = read $ args !! 1
file <- readFile filename
diff --git a/phase2.hs b/phase2.hs
index c126122..5ea60c0 100644
--- a/phase2.hs
+++ b/phase2.hs
@@ -8,7 +8,7 @@ import Control.Monad(when)
main :: IO()
main = do
args <- getArgs
- when (3 /= length args) (error "Usage: phase2 ")
+ when (3 > length args) (error "Usage: phase2 table.csv frequents.csv threshold [out.assoc]")
let threshold = read $ last args
tableFile <- readFile $ head args
freqFile <- readFile $ args !! 1
@@ -18,9 +18,10 @@ main = do
case parseCSV freqFile of
Left _ -> error "Could not parse frequent patterns"
Right freqFileContent -> do
- putStrLn output
- when (length args > 2) $
- writeFile (args !! 2) $ output
+ --putStrLn output
+ print $ zip rules (map (lift table) rules)
+ when (length args > 3) $
+ writeFile (args !! 3) $ output
where
freqPats = map (ItemSet. Set.fromList .map Item) (map tail freqFileContent)
table = map (ItemSet. Set.fromList .map Item) tableFileContent