本文整理汇总了Scala中org.apache.spark.ml.tree.Split类的典型用法代码示例。如果您正苦于以下问题:Scala Split类的具体用法?Scala Split怎么用?Scala Split使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Split类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: SplitToMleap
//设置package包名称以及导入依赖的类
package org.apache.spark.ml.mleap.converter
import com.truecar.mleap.core.tree
import org.apache.spark.ml.tree.{ContinuousSplit, CategoricalSplit, Split}
case class SplitToMleap(split: Split) {
def toMleap: tree.Split = {
split match {
case split: CategoricalSplit =>
val (isLeft, categories) = if(split.leftCategories.length >= split.rightCategories.length) {
(true, split.leftCategories)
} else {
(false, split.rightCategories)
}
val numCategories = split.leftCategories.length + split.rightCategories.length
tree.CategoricalSplit(split.featureIndex, numCategories, categories, isLeft)
case split: ContinuousSplit =>
tree.ContinuousSplit(split.featureIndex, split.threshold)
}
}
}