【发布时间】:2014-09-22 04:21:47
【问题描述】:
我有一个具有相应 categoricalFeaturesInfo 的功能集:Map[Int,Int]。但是,对于我的生活,我无法弄清楚我应该如何让 DecisionTree 类工作。它不会接受任何东西,而是接受 LabeledPoint 作为数据。但是,LabeledPoint 需要 (double, vector) 而向量需要双精度。
val LP = featureSet.map(x => LabeledPoint(classMap(x(0)),Vectors.dense(x.tail)))
// Run training algorithm to build the model
val maxDepth: Int = 3
val isMulticlassWithCategoricalFeatures: Boolean = true
val numClassesForClassification: Int = countPossibilities(labelCol)
val model = DecisionTree.train(LP, Classification, Gini, isMulticlassWithCategoricalFeatures, maxDepth, numClassesForClassification,categoricalFeaturesInfo)
我得到的错误:
scala> val LP = featureSet.map(x => LabeledPoint(classMap(x(0)),Vectors.dense(x.tail)))
<console>:32: error: overloaded method value dense with alternatives:
(values: Array[Double])org.apache.spark.mllib.linalg.Vector <and>
(firstValue: Double,otherValues: Double*)org.apache.spark.mllib.linalg.Vector
cannot be applied to (Array[String])
val LP = featureSet.map(x => LabeledPoint(classMap(x(0)),Vectors.dense(x.tail)))
到目前为止我的资源: tree config,decision tree,labeledpoint
【问题讨论】:
标签: scala apache-spark tree apache-spark-mllib categorical-data