【发布时间】:2019-12-11 03:20:03
【问题描述】:
我正在研究用于二进制分类的分类器。数据不平衡,第 0 类为 83.41%,第 1 类为 16.59%。我正在使用 Mathews 相关系数来评估分类器的性能。另请注意,维度 ((211, 800)) 的数据相当少。
我正在使用逻辑回归来解决问题。我使用 GridSearchCV 进行超参数优化,并得出以下最佳超参数值:
最佳参数:{'C': 1000, 'class_weight': {1: 0.83, 0: 0.17000000000000004}, 'penalty': '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()
根据我对这条曲线的理解,它表明该模型倾向于过度拟合,因为它在验证集上的表现较低而在训练集上的表现较高。谁能指出我如何在如此小的数据集上解决这个问题的方向。
【问题讨论】: