Decision Tree 구축하기
이제 항공편 데이터를 학습용과 테스트용으로 분할했으니, 학습용 데이터로 Decision Tree 모델을 학습시켜 보세요.
데이터는 flights_train과 flights_test로 제공됩니다.
NOTE: 모델 학습에 몇 초 정도 걸릴 수 있어요. 잠시만 기다려 주세요!
이 연습은 강의의 일부입니다
PySpark로 하는 Machine Learning
연습 안내
- Decision Tree 분류기를 생성하는 클래스를 임포트하세요.
- 분류기 객체를 만들고 학습용 데이터에 맞춰 학습시키세요.
- 테스트용 데이터에 대해 예측을 수행하고 예측 결과를 확인하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# 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)