{-# LANGUAGE OverloadedLists #-} module Clustering.FrequentItemSet.AprioriSpec where import Control.Monad (Monad (..)) import Data.List qualified as List import Test.Syd import Test.Syd.Validity import Clustering.FrequentItemSet.Apriori spec = do describe "frequentItemSets" do it "solves Takeaki Uno example" do -- From https://research.nii.ac.jp/~uno/code/lcm.html#IntroductionstoFrequentItemsetMining ( frequentItemSets [ [1, 2, 5, 6, 7] , [2, 3, 4, 5] , [1, 2, 7, 8, 9] , [1, 7, 9] , [2, 7, 9] , [2, 7, 9] -- Copy-paste typo on the original example , [1, 9] -- Add this to increase the support of [1,9] because the original example is wrong… , [2] ] 3 ) `shouldBe` [ [] , [1] , [1, 7] , [1, 9] , [2] , [2, 7] , [2, 7, 9] , [2, 9] , [7] , [7, 9] , [9] ] {- it "solves a singleton transaction" do naiveClosedFrequentItemSets [ [1] ] 1 `shouldBe` [ [1] ] it "solves a basic example" do naiveClosedFrequentItemSets [ [1] , [1,2] ] 1 `shouldBe` [ [1] , [1, 2] ] it "solves a another basic example" do naiveClosedFrequentItemSets [ [1] , [1,2] , [1,2] ] 1 `shouldBe` [ [1] , [1, 2] ] it "" do naiveClosedFrequentItemSets [ [1,2,3,4,5,6] , [2,3,5] , [2,5] , [1,2,4,5,6] , [2,4] , [1,4,6] , [3,4,6] ] 3 `shouldBe` [ [4] , [2] , [2,4] , [4,6] , [2,5] , [3] , [1,4,6] ] -}