小编use*_*547的帖子

使用Python的随机森林特征重要性图表

我在python中使用RandomForestRegressor,我想创建一个图表来说明功能重要性的排名.这是我使用的代码:

from sklearn.ensemble import RandomForestRegressor

MT= pd.read_csv("MT_reduced.csv") 
df = MT.reset_index(drop = False)

columns2 = df.columns.tolist()

# Filter the columns to remove ones we don't want.
columns2 = [c for c in columns2 if c not in["Violent_crime_rate","Change_Property_crime_rate","State","Year"]]

# Store the variable we'll be predicting on.
target = "Property_crime_rate"

# Let’s randomly split our data with 80% as the train set and 20% as the test set:

# Generate the training set.  Set random_state to be able to replicate results.
train2 = …
Run Code Online (Sandbox Code Playgroud)

python plot feature-selection random-forest

15
推荐指数
4
解决办法
4万
查看次数

标签 统计

feature-selection ×1

plot ×1

python ×1

random-forest ×1