]> Git — Sourcephile - literate-phylomemy.git/blob - tests/Clustering/FrequentItemSet/AprioriSpec.hs
completeness(scale): add support for scale
[literate-phylomemy.git] / tests / Clustering / FrequentItemSet / AprioriSpec.hs
1 {-# LANGUAGE OverloadedLists #-}
2
3 module Clustering.FrequentItemSet.AprioriSpec where
4
5 import Control.Monad (Monad (..))
6 import Data.List qualified as List
7 import Test.Syd
8 import Test.Syd.Validity
9
10 import Clustering.FrequentItemSet.Apriori
11
12 spec = do
13 describe "frequentItemSets" do
14 it "solves Takeaki Uno example" do
15 -- From https://research.nii.ac.jp/~uno/code/lcm.html#IntroductionstoFrequentItemsetMining
16 ( frequentItemSets
17 [ [1, 2, 5, 6, 7]
18 , [2, 3, 4, 5]
19 , [1, 2, 7, 8, 9]
20 , [1, 7, 9]
21 , [2, 7, 9]
22 , [2, 7, 9] -- Copy-paste typo on the original example
23 , [1, 9] -- Add this to increase the support of [1,9] because the original example is wrong…
24 , [2]
25 ]
26 3
27 )
28 `shouldBe` [ []
29 , [1]
30 , [1, 7]
31 , [1, 9]
32 , [2]
33 , [2, 7]
34 , [2, 7, 9]
35 , [2, 9]
36 , [7]
37 , [7, 9]
38 , [9]
39 ]
40
41 {-
42 it "solves a singleton transaction" do
43 naiveClosedFrequentItemSets
44 [ [1]
45 ] 1 `shouldBe`
46 [ [1]
47 ]
48 it "solves a basic example" do
49 naiveClosedFrequentItemSets
50 [ [1]
51 , [1,2]
52 ] 1 `shouldBe`
53 [ [1]
54 , [1, 2]
55 ]
56 it "solves a another basic example" do
57 naiveClosedFrequentItemSets
58 [ [1]
59 , [1,2]
60 , [1,2]
61 ] 1 `shouldBe`
62 [ [1]
63 , [1, 2]
64 ]
65 it "" do
66 naiveClosedFrequentItemSets
67 [ [1,2,3,4,5,6]
68 , [2,3,5]
69 , [2,5]
70 , [1,2,4,5,6]
71 , [2,4]
72 , [1,4,6]
73 , [3,4,6]
74 ] 3 `shouldBe`
75 [ [4]
76 , [2]
77 , [2,4]
78 , [4,6]
79 , [2,5]
80 , [3]
81 , [1,4,6]
82 ]
83 -}