인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

freedom07's profile image
freedom07

asked

[Revised Edition] The Complete Guide to Python Machine Learning

Introduction to scikit-learn and overview of machine learning classification prediction models

DecisionTreeClassifier 객체 생성시 random_state하는 이유?

Written on

·

919

0

선생님~

학습 데이터와 테스트 데이터 세트로 분리를 할 때 

X_train, X_test, y_train, y_test = train_test_split(iris_data, iris_label,  test_size=0.2, random_state=11)

이렇게 random_state 를 쓰는 이유는 이해가 되는데..

(반복실행해도 train데이터셋과 test데이터셋을 나눈 결과를 똑같이(고정하는 의미) 보이게 하려고)

DecisionTreeClassifier 객체를 생성시,  

dt_clf = DecisionTreeClassifier(random_state=11)

이렇게 rrandom_state를 쓰는 이유는 무엇인가요~?

python머신러닝 배워볼래요? 통계

Answer 1

1

dooleyz3525님의 프로필 이미지
dooleyz3525
Instructor

DecisionTree도 비슷합니다. 다만 DecisionTree의 내부 알고리즘이 구동시 random하게 feature들과 데이터 건수를 선택하는 로직이 포함되어 있습니다.

때문에 random_state로 특정값을 지정하여 DecisionTree 수행시 마다 동일한 Rule 트리를 만들 수 있도록 합니다

freedom07's profile image
freedom07

asked

Ask a question