【发布时间】:2018-06-21 10:46:16
【问题描述】:
我最近在 kaggle (Shape : 1646801, 150) 的这个数据集上建立了一个预测模型(逻辑回归)。然而,经过简单的预处理后,我得到了非常不寻常的 99.9% 的准确率。资料:https://www.kaggle.com/wordsforthewise/lending-club
采取的步骤:
- 映射不同的loan_status ('Fully_Paid'、'Default'、'Charged Off')到default (0,1)
- 查找每列的 null 值的计数,如果 null > 10000,remove column
- 删除其他空值的行,形状为左(814392, 51)
- 删除成绩并将 sub_grade ('A1', 'A3') 映射为 integer (0, 2)时间>
- 单热编码
- 使用逻辑回归建模(类标签比例为 1:4)
对于建模部分,我首先使用 train-test split 并获得 99.9% 的准确率。我还检查了混淆矩阵,TP 和 TN 都很高。我还检查了功能的重要性,这些功能看起来很正常,似乎没有任何功能明显优于其他功能。我也试过5折和10折交叉验证,准确率还是很高的。
以下是建模代码,如果它似乎有助于解决问题,我将显示任何预处理代码。
y = df2[['default']].values.ravel()
X = df2.drop(columns = 'default').values
X_train, X_test, y_train, y_test=train_test_split(X, y, test_size=.2)
features = df2.drop(columns = 'default').columns.tolist()
LR = model.LogisticRegression()
LR.fit(X_train,y_train)
y_pred = LR.predict(X_test)
print('Accuracy : ', metrics.accuracy_score(y_test, y_pred))
print('\n', metrics.classification_report(y_test, y_pred))
print('Confusion Matrix')
print(metrics.confusion_matrix(y_test, y_pred))
似乎是什么问题?那是我做错了什么吗?
【问题讨论】:
-
你有几节课?还有什么比例
-
2个班级和4:1的比例
标签: python machine-learning logistic-regression prediction