This recipe is similar to the GBT problem, but we will use regression instead. We will use BoostingStrategy.defaultParams()
to direct the GBT to regression:
algo = "Regression" val boostingStrategy = BoostingStrategy.defaultParams(algo)
- Start a new project in IntelliJ or in an IDE of your choice. Make sure the necessary JAR files are included.
- Set up the package location where the program will reside:
.package spark.ml.cookbook.chapter10
- Import the necessary packages for the Spark context:
import org.apache.spark.mllib.evaluation.RegressionMetrics import org.apache.spark.mllib.linalg.Vectors import org.apache.spark.mllib.regression.LabeledPoint import org.apache.spark.mllib.tree.model.GradientBoostedTreesModel import org.apache.spark.rdd.RDD import org.apache.spark.mllib.tree.GradientBoostedTrees import org.apache.spark.mllib.tree.configuration.BoostingStrategy import org.apache.spark.sql.SparkSession...