반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

sklearn.RandomForestClassifier.feature_importances_(중요도 표현) 본문

[AI]/python.sklearn

sklearn.RandomForestClassifier.feature_importances_(중요도 표현)

givemebro 2020. 4. 20. 15:03
반응형

https://broscoding.tistory.com/160

 

머신러닝.RandomForestClassifier.기초

import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.datasets import load_breast_cancer cancer=load_breast_cancer() X_train,X_test,y_t..

broscoding.tistory.com

 

model = RandomForestClassifier(n_estimators=100, max_depth=5) # default is 10
model.fit(cancer.data, cancer.target)

# 랜덤 포레스트 모델 생성시 가장 중요하게 영향을 끼친 속성
weight = model.feature_importances_

plt.figure(figsize=[10,10])
plt.barh(range(30),weight)
plt.yticks(range(30),['%s(%d)' % (s,i) for i,s in enumerate(cancer.feature_names)],va='bottom')
print('')

반응형
Comments