-2
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)

please any help error: reassignment to val greaccuracy = accuracy ^

  • 4
    Possible duplicate of [Use of def, val, and var in scala](http://stackoverflow.com/questions/4437373/use-of-def-val-and-var-in-scala) – Andrey Moiseev Nov 21 '16 at 22:23

1 Answers1

2

val are immutable variables, once set you cannot change them. That's by designed. var on other hand you can change them.