1 {-# LANGUAGE OverloadedLists #-}
3 module Clustering.FrequentItemSet.BruteForceSpec where
5 import Data.Either (fromRight)
6 import Data.Function (($))
7 import Data.Functor ((<$>))
10 import Data.Ratio ((%))
12 import Logic.Theory.Arithmetic
13 import Logic.Theory.Ord
14 import Numeric.Probability (probability)
16 import Prelude (Num, undefined)
18 import Clustering.FrequentItemSet.BruteForce
20 exampleTakeakiUnoDB :: Ord item => Num item => Transactions item
27 , [2, 7, 9] -- Copy-paste typo on the original example
28 , [1, 9] -- Add this to increase the support of [1,9] because the original example is wrong…
34 describe "frequentItemSets" do
35 it "computes Takeaki Uno's example" $
36 -- From https://research.nii.ac.jp/~uno/code/lcm.html#IntroductionstoFrequentItemsetMining
37 letName 3 \(\x -> x / fromRight undefined (prove (x > zero)) -> minSupp) ->
38 -- Alas, this is not a zero-cost `coerce`
39 unName <$> allFrequentItemSets @Int (nameless exampleTakeakiUnoDB) minSupp
52 describe "associationRules" do
53 proba75 <- liftIO (probability (75 % 100))
54 it "computes Takeaki Uno's example" do
55 let db = nameless exampleTakeakiUnoDB
56 let minSupp = let x = nameless 2 in x / fromRight undefined (prove (x > zero))
57 goldenPrettyShowInstance
58 "tests/Clustering/FrequentItemSet/BruteForce/associationRules/TakeakiUno.golden"
59 [ associationRules fis db (nameless proba75)
60 | fis <- allFrequentItemSets @Int db minSupp