- https://stackoverflow.com/questions/49345578/how-to-decide-threshold-value-in-selectfrommodel-for-selecting-features
思考:
1)参照该博客中基于随机森林的特征重要性排序并打印代码,修改成基于SVM的特征重要性排序并打印。
文中先基于随机森林分类器训练模型,再将训练完的模型中的特征进行排序并打印出来
原代码如下:
feat_labels = data.columns[1:]
clf = RandomForestClassifier(n_estimators=100, random_state=0)
# Train the classifier
clf.fit(X_train, y_train)
importances = clf.feature_importances_
indices = np.argsort(importances)[::-1]
for f in range(X_train.shape[1]):
print("%2d) %-*s %f" % (f + 1, 30, feat_labels[indices[f]], importances[indices[f]]))
结果:
参考该思路实