본문 바로가기
인공지능/Machine Learning

[Machine Learning] 분류예측 RandomForestClassifier

by coding_su 2022. 12. 2.

📝머신러닝 RandomForestClassifier (Decision Tree 개선한 모델)

from sklearn.ensemble import RandomForestClassifier

 

RandomForestClassifier()

# 변수에 저장하여 사용
classifier = RandomForestClassifier( n_estimators=200 )
# n_estimators= 트리 갯수 지정(디폴트값 100)

classifier = RandomForestClassifier()

# 학습, 테스트
classifier.fit(X_train, y_train)
y_pred = classifier.predict(X_test)

# 예측
from sklearn.metrics import confusion_matrix, accuracy_score

confusion_matrix(y_test, y_pred)
accuracy_score(y_test, y_pred)

댓글