O'Reilly logo

Machine Learning with Spark - Second Edition by Nick Pentreath, Manpreet Singh Ghotra, Rajdeep Dua

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The impact of parameter settings for the decision tree

Decision trees provide two main parameters: maximum tree depth and maximum number of bins. We will now perform the same evaluation of the effect of parameter settings for the decision tree model. Our starting point is to create an evaluation function for the model, similar to the one used for the linear regression earlier. This function is provided here:

Scala

def evaluate(train: RDD[LabeledPoint],test: RDD[LabeledPoint],   categoricalFeaturesInfo: scala.Predef.Map[Int, Int],   maxDepth :Int, maxBins: Int): Double = {     val impurity = "variance"     val decisionTreeModel = DecisionTree.trainRegressor(train,       categoricalFeaturesInfo,       impurity, maxDepth, maxBins)  val true_vs_predicted = test.map(p ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required