Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/7818#discussion_r36024376
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/fpm/LocalPrefixSpan.scala ---
@@ -39,12 +39,20 @@ private[fpm] object LocalPrefixSpan extends Logging
with Serializable {
def run(
minCount: Long,
maxPatternLength: Int,
- prefixes: List[Int],
- database: Iterable[Array[Int]]): Iterator[(List[Int], Long)] = {
- if (prefixes.length == maxPatternLength || database.isEmpty) return
Iterator.empty
- val frequentItemAndCounts = getFreqItemAndCounts(minCount, database)
- val filteredDatabase = database.map(x =>
x.filter(frequentItemAndCounts.contains))
- frequentItemAndCounts.iterator.flatMap { case (item, count) =>
+ prefixes: List[Set[Int]],
+ database: Iterable[List[Set[Int]]]): Iterator[(List[Set[Int]],
Long)] = {
+ if (prefixes.length == maxPatternLength || database.isEmpty) {
+ return Iterator.empty
+ }
+ val freqItemSetsAndCounts = getFreqItemAndCounts(minCount, database)
+ val freqItems = freqItemSetsAndCounts.keys.flatten.toSet
+ val filteredDatabase = database.map { suffix =>
+ suffix
+ .map(item => freqItems.intersect(item))
+ .filterNot(_.isEmpty)
+
--- End diff --
remove blank line
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]