Python 3.x 如何避免不平衡数据的过度拟合?

Python 3.x 如何避免不平衡数据的过度拟合?,python-3.x,scikit-learn,Python 3.x,Scikit Learn,我正在为二元分类设计一个分类器。数据不平衡,0类为83.41%,1类为16.59%。我使用Mathews相关系数来评估分类器的性能。还请注意,维度((211800))的数据非常少 我使用逻辑回归来解决这个问题。我使用GridSearchCV进行超参数优化,并得出以下最佳超参数值: 最佳参数:{C':1000,'class_-weight':{1:0.83,0:0.17000000000000004},'惩罚':'l1','solver':'liblinear'} 最佳MCC 0.70450535

我正在为二元分类设计一个分类器。数据不平衡,0类为83.41%,1类为16.59%。我使用Mathews相关系数来评估分类器的性能。还请注意,维度((211800))的数据非常少

我使用逻辑回归来解决这个问题。我使用GridSearchCV进行超参数优化,并得出以下最佳超参数值:

最佳参数:{C':1000,'class_-weight':{1:0.83,0:0.17000000000000004},'惩罚':'l1','solver':'liblinear'}

最佳MCC 0.7045053547679334

我绘制了C值范围内的验证曲线,以检查模型是否过拟合/欠拟合

train_scores, test_scores = validation_curve(LogisticRegression(penalty='l1',
                                                                solver='liblinear',
                                                                class_weight={1: 0.83, 0: 0.17000000000000004}),
                                             X, y,'C', C, cv=5, scoring=make_scorer(matthews_corrcoef))
train_scores_mean = np.mean(train_scores, axis=1)
train_scores_std = np.std(train_scores, axis=1)
test_scores_mean = np.mean(test_scores, axis=1)
test_scores_std = np.std(test_scores, axis=1)

plt.title("Validation Curve with Logistic Regression")
plt.xlabel("C")
plt.ylabel("MCC")
plt.ylim(0.0, 1.1)
lw = 2
plt.semilogx(C, train_scores_mean, label="Training score",
             color="darkorange", lw=lw)
plt.fill_between(C, train_scores_mean - train_scores_std,
                 train_scores_mean + train_scores_std, alpha=0.2,
                 color="darkorange", lw=lw)
plt.semilogx(C, test_scores_mean, label="Cross-validation score",
             color="navy", lw=lw)
plt.fill_between(C, test_scores_mean - test_scores_std,
                 test_scores_mean + test_scores_std, alpha=0.2,
                 color="navy", lw=lw)
plt.legend(loc="best")
plt.show()


根据我对这条曲线的理解,它表明该模型倾向于过度拟合,因为它在验证集上的性能较低,而在训练集上的性能较高。有谁能告诉我一些方向,如何在如此小的数据集上解决这个问题

你可以做很多事情:

  • 用于对少数族裔进行过采样
  • 减少GridSearchCV的迭代次数或使用RandomSearchCV

  • 因为在SMOTE之后,这些类最终会达到平衡,我应该继续使用MCC进行fo还是切换到任何其他度量?您可以使用