擅长:python、mysql、java
<p>您可以在模型中使用xgboost,通过使用plot-importance(model)方法以简单的方式绘制要素的重要性</p>
<p><code>from xgboost import plot_importance,XGBClassifier
model=XGBClassifier(n_estimators=1000,learning_rate=0.5)
x_train,x_test,y_train,y_test=model_selection.train_test_split(features,label,test_size=0.2)
model.fit(x_train,y_train,early_stopping_rounds=5,eval_set=[(x_test,y_test)])
plot_importance(model)
plt.show()</code></p>
<p>这段代码将为您提供如下绘图:</p>
<p><a href="https://i.stack.imgur.com/5iW61.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5iW61.png" alt="graph with labeled feature names on y axis sorted according to importance and their importance labeled on x axis"/></a></p>