Gradient-Boosted Trees
Setting Up Gradient-Boosted Tree Regression
Load in required libraries
from pyspark.ml.regression import GBTRegressor
from pyspark.ml.tuning import ParamGridBuilder, CrossValidator
from pyspark.ml.evaluation import RegressionEvaluatorInitialize Gradient-Boosted Tree object
gb = GBTRegressor(labelCol="label", featuresCol="features")Create a parameter grid for tuning the model
gbparamGrid = (ParamGridBuilder()
.addGrid(gb.maxDepth, [2, 5, 10])
.addGrid(gb.maxBins, [10, 20, 40])
.addGrid(gb.maxIter, [5, 10, 20])
.build())Define how you want the model to be evaluated
Define the type of cross-validation you want to perform
Fit the model to the data
Score the testing dataset using your fitted model for evaluation purposes
Evaluate the model
Last updated
Was this helpful?