Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Machine Learning with PySpark

Cursus bekijken

Oefeninstructies

  • 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.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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.____)
Code bewerken en uitvoeren