减少分类模型过拟合的特征选择方法

Feature selection methodology to reduce Overfit in classification model

我的数据集有 200 多个变量,我是 运行 它的一个分类模型,这导致模型过拟合。哪个建议减少功能的数量?我从特征重要性开始,但是由于变量太多,我无法将其可视化。有没有一种方法可以根据给定变量绘制或展示这些值?

下面是正在尝试的代码:

F_Select = ExtraTreesClassifier(n_estimators=50)
F_Select.fit(X_train,y_train)
print(F_Select.feature_importances_)

您可以尝试从最大到最小绘制特征重要性,并查看哪些特征捕获了一定数量(比如 95%)的方差,就像 PCA 中使用的碎石图一样。理想情况下,这应该是少量特征:

import matplotlib.pyplot as plt
from sklearn import *
model = ensemble.RandomForestClassifier()
model.fit(features, labels)
model.feature_importances_
importances = np.sort(model.feature_importances_)[::-1]
cumsum = np.cumsum(importances)
plt.bar(range(len(importances)), importances)
plt.plot(cumsum)