공부/A.I

[앙상블 모델] Random forest2

래울 2021. 6. 27. 20:03

2021.06.19 - [공부/A.I] - [앙상블 모델] Random forest

 

[앙상블 모델] Random forest

https://books.google.co.kr/books?id=tPaTDwAAQBAJ&lpg=PP1&dq=python%20%EB%9D%BC%EC%9D%B4%EB%B8%8C%EB%9F%AC%EB%A6%AC%EB%A5%BC%20%ED%99%9C&hl=ko&pg=PP1#v=onepage&q&f=false 파이썬 라이브러리를 활용한 머..

doraeul19.tistory.com


- 보다 많은 트리로 이루어진 랜덤 포레스트

from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
from sklearn.datasets import load_breast_cancer

cancer = load_breast_cancer()
X_train, X_test, y_train, y_test = train_test_split(
    cancer.data, cancer.target, random_state=0)
forest = RandomForestClassifier(n_estimators=100, random_state=10)
forest.fit(X_train, y_train)
print("훈련세트 정확도 : %.2f" %forest.score(X_train, y_train))
print("테스트세트 정확도 : %.2f" %forest.score(X_test, y_test))