Get startedGet started for free

Delayed flights with Gradient-Boosted Trees

You've previously built a classifier for flights likely to be delayed using a Decision Tree. In this exercise you'll compare a Decision Tree model to a Gradient-Boosted Trees model.

The flights data have been randomly split into flights_train and flights_test.

This exercise is part of the course

Machine Learning with PySpark

View Course

Exercise instructions

  • Import the classes required to create Decision Tree and Gradient-Boosted Tree classifiers.
  • Create Decision Tree and Gradient-Boosted Tree classifiers. Train on the training data.
  • Create an evaluator and calculate AUC on testing data for both classifiers. Which model performs better?
  • For the Gradient-Boosted Tree classifier print the number of trees and the relative importance of features.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import the classes required
from pyspark.ml.____ import ____, ____
from pyspark.ml.evaluation import BinaryClassificationEvaluator

# Create model objects and train on training data
tree = ____().____(____)
gbt = ____().____(____)

# Compare AUC on testing data
evaluator = ____()
print(evaluator.____(tree.____(____)))
print(evaluator.____(gbt.____(____)))

# Find the number of trees and the relative importance of features
print(gbt.____)
print(gbt.____)
Edit and Run Code