'''랜덤 포레스트는 일반적으로 배깅 방법을 적용한 결정 트리의 앙상블
엑스트라 트리 (익스트림 랜덤 트리 앙상블)
-극단적으로 무작위한 트리의 랜덤 포레스트
-편향이 늘어나지만 대신 분산을 낮춤
-사이킷런의 ExtraTreesClassifier응 사용
특성 중요도
-랜덤 포레스트의 또 다른 장점은 특성의 상대적 중요도를 측정하기 쉽다는 점
-사이킷런은 훈련이 끝난 뒤 특성마다 자동으로 중요도의 전체합이 1이 되도록 결과값을 정규화
-iris 데이터에 RandomForestClassFier을 훈련시키고 각 특성의 중요도를 출력하는 코드.
꽃잎의 길이(44%)와 너비(42%)
'''
from sklearn.datasets import load_iris
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
import warnings
warnings.filterwarnings('ignore')
iris_data = load_iris()
print(iris_data)
clf = RandomForestClassifier(n_estimators=50, max_depth=6, random_state=0)
clf.fit(iris_data.data,iris_data.target)
for name,answer in zip(iris_data.feature_names,clf.feature_importances_):
print(name,answer)
'Python' 카테고리의 다른 글
Python - XGB, HGBM 파라미터 튜닝 , 캐글 점수 (0) | 2022.10.21 |
---|---|
Python - Grid Search Hyper parameter (0) | 2022.10.19 |
Python - 머신러닝 모델 평가 [최종] (0) | 2022.10.17 |
Python - 모델평가 함수 (0) | 2022.10.17 |
Python - 모델 평가 오차행렬 (0) | 2022.10.17 |