首页 > 代码库 > 基于Spark的FPGrowth源码中难啃的骨头
基于Spark的FPGrowth源码中难啃的骨头
/** Extracts all patterns with valid suffix and minimum count. */ def extract( minCount: Long, validateSuffix: T => Boolean = _ => true): Iterator[(List[T], Long)] = { summaries.iterator.flatMap { case (item, summary) => if (validateSuffix(item) && summary.count >= minCount) { Iterator.single((item :: Nil, summary.count)) ++ project(item).extract(minCount).map { case (t, c) => (item :: t, c) } } else { Iterator.empty } } }
分析:waiting
/** Adds a transaction with count. */ def add(t: Iterable[T], count: Long = 1L): this.type = { require(count > 0) var curr = root curr.count += count t.foreach { item => val summary = summaries.getOrElseUpdate(item, new Summary) summary.count += count val child = curr.children.getOrElseUpdate(item, { val newNode = new Node(curr) newNode.item = item summary.nodes += newNode newNode }) child.count += count curr = child } this }
分析:waiting
/** Returns all transactions under this node. */ private def getTransactions(node: Node[T]): Iterator[(List[T], Long)] = { var count = node.count node.children.iterator.flatMap { case (item, child) => getTransactions(child).map { case (t, c) => count -= c (item :: t, c) } } ++ { if (count > 0) { Iterator.single((Nil, count)) } else { Iterator.empty } } }
分析:waiting
基于Spark的FPGrowth源码中难啃的骨头
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。