MulaiMulai sekarang secara gratis

Build a Decision Tree

Now that you've split the flights data into training and testing sets, you can use the training set to fit a Decision Tree model.

The data are available as flights_train and flights_test.

NOTE: It will take a few seconds for the model to train… please be patient!

Latihan ini adalah bagian dari kursus

Machine Learning with PySpark

Lihat Kursus

Petunjuk latihan

  • Import the class for creating a Decision Tree classifier.
  • Create a classifier object and fit it to the training data.
  • Make predictions for the testing data and take a look at the predictions.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Import the Decision Tree Classifier class
from pyspark.ml.____ import ____

# Create a classifier object and fit to the training data
tree = ____()
tree_model = tree.____(____)

# Create predictions for the testing data and take a look at the predictions
prediction = tree_model.____(____)
prediction.select('label', 'prediction', 'probability').show(5, False)
Edit dan Jalankan Kode