-1
val numClasses = 5
val categoricalFeaturesInfo = Map[Int, Int]()
val impurity = "gini"
val maxDepth = 0
val maxBins = 32
val greaccuracy = 0
for(maxDepth <- 0 to 30){
val model = DecisionTree.trainClassifier(trainData, numClasses, categoricalFeaturesInfo, impurity, maxDepth, maxBins)
val metrics = getMetrics(model, cvData)
val accuracy = metrics.precision
if (accuracy > greaccuracy){
greaccuracy = accuracy
}
}
println("Accuracy = "+greaccuracy)
請任何幫助 錯誤:重新分配給VAL greaccuracy =準確性 ^交換兩個可變由Scala語言
[在scala中使用def,val和var]可能的重複(http://stackoverflow.com/questions/4437373/use-of-def-val-and-var-in-scala) –