如何查看非线性核函数SVM模型的特征重要性
如何查看非线性核函数SVM模型的特征重要性
由于使用了非线性核函数,无法直接获取模型的系数。如果想要查看特征的重要性,可以考虑使用其他方法,如随机森林的feature_importances_属性。
修改后的代码:
import joblib
best_model = grid_search.best_estimator_
joblib.dump(best_model,'best_model.pkl')
importances = best_model.feature_importances_
plt.bar(range(len(importances)), importances)
plt.xticks(range(len(importances)), X.columns, rotation=90)
plt.xlabel('Features')
plt.ylabel('Importance')
plt.show()
这样可以绘制特征的重要性柱状图,来观察各个特征对模型的贡献程度。
原文地址: https://www.cveoy.top/t/topic/qgp6 著作权归作者所有。请勿转载和采集!