运城网站建设兼职,廊坊建网站外包,北京海淀区公司,网站设计要注意事项实现功能
排列重要性 PermutationImportance#xff1a;该方法会随机排列每个特征的值#xff0c;然后监控模型性能下降的程度。如果获得了更大的下降意味着特征更重要
实现代码 from sklearn.datasets import load_breast_cancer
from sklearn.ensemble import RandomFore…实现功能
排列重要性 PermutationImportance该方法会随机排列每个特征的值然后监控模型性能下降的程度。如果获得了更大的下降意味着特征更重要
实现代码 from sklearn.datasets import load_breast_cancer
from sklearn.ensemble import RandomForestClassifier
from sklearn.inspection import permutation_importance
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as pltcancer load_breast_cancer()X_train, X_test, y_train, y_test train_test_split(cancer.data, cancer.target, random_state1)rf RandomForestClassifier(n_estimators100, random_state1)
rf.fit(X_train, y_train)baseline rf.score(X_test, y_test)
result permutation_importance(rf, X_test, y_test, n_repeats10, random_state1, scoringaccuracy)importances result.importances_mean# Visualize permutation importances
plt.style.use(ggplot)
plt.figure(figsize(10, 8))
plt.bar(range(len(importances)), importances)
plt.xlabel(Feature Index)
plt.ylabel(Permutation Importance)
plt.show()
实现效果 本人读研期间发表5篇SCI数据挖掘相关论文现在某研究院从事数据挖掘相关科研工作对数据挖掘有一定认知和理解会结合自身科研实践经历不定期分享关于python机器学习、深度学习、数据挖掘基础知识与案例。 致力于只做原创以最简单的方式理解和学习关注我一起交流成长。 邀请三个朋友关注V订阅号数据杂坛即可在后台联系我获取相关数据集和源码送有关数据分析、数据挖掘、机器学习、深度学习相关的电子书籍。