如何在条形图上拥有更少的条形图?
我正在构建随机森林算法,目的是预测哪些功能更重要。我的条形图显示了从随机森林内置特征重要性中重要的特征。与较大的条形相比,是否有机会过滤数据相对较小的数据以及如何实施此数据。我想这样做是因为下面的这些图片上有一团糟:
输入代码:
rf = RandomForestRegressor(n_estimators=100, max_depth=3)
rf.fit(X_train, y_train)
sorted_idx = rf.feature_importances_.argsort()
plt.figure(figsize=(8, 30))
plt.barh(X_train.columns[sorted_idx], rf.feature_importances_[sorted_idx])
plt.xlabel("Random Forest Feature Importance")
I am building Random forest algorithm, the goal is to predict which features are more important. And I have Bar graph showing features importance from Random Forest Built-in Feature Importance. Is there a chance to filter out data that are relatively smaller compared to larger bars and how to implement this. I want to do these because there is a mess on these picture below:
Input code:
rf = RandomForestRegressor(n_estimators=100, max_depth=3)
rf.fit(X_train, y_train)
sorted_idx = rf.feature_importances_.argsort()
plt.figure(figsize=(8, 30))
plt.barh(X_train.columns[sorted_idx], rf.feature_importances_[sorted_idx])
plt.xlabel("Random Forest Feature Importance")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过过滤
sorted_idx
变量,您应该能够这样做:显然,您可以采用任何要绘制的功能。
By filtering the
sorted_idx
variable, you should be able to do so:Instead of 5, you can obviously take whatever number of features you want to be plotted.