How it works...

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.05370763765769276
My regression GBT model:
Tree 0:
If (feature 1 <= 2.0)
If (feature 0 <= 6.0)
If (feature 5 <= 5.0)
If (feature 5 <= 4.0)
Predict: 0.0
Else (feature 5 > 4.0)
...
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.156.122