Created
January 20, 2019 19:43
-
-
Save rayfix/38fd6564e5e7b84b87b24bd4d75b1566 to your computer and use it in GitHub Desktop.
ECLAT Frequent Pattern Matching in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var accumulatedItemSets = Dictionary(uniqueKeysWithValues: database.map { | |
(Set([$0.key]), Set($0.value)) }) | |
var itemSetsToEvaluate = accumulatedItemSets | |
while !itemSetsToEvaluate.isEmpty { | |
var temp: [Set<String>: Set<Int>] = [:] | |
itemSetsToEvaluate.pairs().forEach { a, b in | |
let key = a.key.union(b.key) | |
let value = a.value.intersection(b.value) | |
if value.count >= absoluteSupport { | |
temp[key] = value | |
} | |
} | |
accumulatedItemSets.merge(temp) { $1 } | |
itemSetsToEvaluate = temp | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment