markdown 随机森林特征重要性可视化
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 随机森林特征重要性可视化相关的知识,希望对你有一定的参考价值。
# Ordinary Model Construction : model_rf
imp_features = pd.Series(model_rf.feature_importances_, index=X_train.columns).sort_values(ascending=False)
imp_features.plot(kind='bar', title='Feature Importance with Random Forest', figsize=(12,8))
plt.ylabel('Feature Importance Values')
plt.subplots_adjust(bottom=0.25)
plt.show()
# Pipeline Construction : pipe_rf
pipe_rf = Pipeline([('scl', StandardScaler()),
('reg', RandomForestRegressor(n_estimators = 500, random_state = 10))])
pipe_rf.fit(X_train, y_train)
imp_features = pd.Series(pipe_rf.steps[1][1].feature_importances_, index=X_train.columns).sort_values(ascending=False)
imp_features.plot(kind='bar', title='Feature Importance with Random Forest', figsize=(12,8))
plt.ylabel('Feature Importance Values')
plt.subplots_adjust(bottom=0.25)
plt.show()
# ML - Random Forest Feature Importance Visualization
###### tags: `Python` `Machine Learning`

以上是关于markdown 随机森林特征重要性可视化的主要内容,如果未能解决你的问题,请参考以下文章