Python sklearn中基于情节的特征排序

Python sklearn中基于情节的特征排序,python,scikit-learn,Python,Scikit Learn,有没有更好的解决方案可以在sklearn中对具有plot的功能进行排名 我写道: from sklearn.feature_selection import RFE from sklearn.linear_model import LogisticRegression model = LogisticRegression() rfe = RFE(model, 3) fit = rfe.fit(X, Y) print( fit.n_features_) print(fit.support_)

有没有更好的解决方案可以在sklearn中对具有plot的功能进行排名

我写道:

from sklearn.feature_selection import RFE

from sklearn.linear_model import LogisticRegression

model = LogisticRegression()
rfe = RFE(model, 3)
fit = rfe.fit(X, Y)

print( fit.n_features_)
print(fit.support_) 
print(fit.ranking_)
输出:

3
[ True False False False False True True False ]
[ 1 2 3 5 6 1 1 4]

从sklearn检验图特征的排列重要性,通过它们的排序

from sklearn.ensemble import RandomForestClassifier
from sklearn.inspection import permutation_importance

X, y = make_classification(random_state=0, n_features=5, n_informative=3)

rf = RandomForestClassifier(random_state=0).fit(X, y)
result = permutation_importance(rf, X, y, n_repeats=10, random_state=0, n_jobs=-1)

fig, ax = plt.subplots()
sorted_idx = result.importances_mean.argsort()
ax.boxplot(result.importances[sorted_idx].T, vert=False, labels=range(X.shape[1]))
ax.set_title("Permutation Importance of each feature")
ax.set_ylabel("Features")
fig.tight_layout()
plt.show()

欢迎使用堆栈溢出!如果你能更清楚地描述这个问题会有帮助的。“更好”的解决方案意味着什么?你目前的产出是什么?你的预期产出是什么?谢谢,我的意思是以视觉方式绘制排名。我的当前输出是数字。我将用输出编辑我的问题。