We used the same GBT tree as the previous recipe, but we adjusted the parameters to direct the GBT API to perform regression as opposed to classification. It is noteworthy to compare the following code with the previous recipe. "Regression" is used to direct the GBT to perform regression on the data:
val algo = "Regression" val numIterations = 3 val maxDepth = 5 val maxBins = 32 val categoricalFeatureInfo = Map[Int,Int]() val boostingStrategy = BoostingStrategy.defaultParams(algo)
We use the following API to train and evaluate the metrics from the model:
- GradientBoostedTrees.train()
- getMetrics()
The following snippet shows a typical output needed to examine the model:
Test Mean Squared Error = 0.05370763765769276My regression ...