【发布时间】:2020-08-10 06:13:23
【问题描述】:
我正在研究医疗保险欺诈检测模型。数据非常不平衡,有 14 个欺诈性阳性案例和大约 100 万个非欺诈性案例。我最初有 8 个特征,但是通过对分类变量进行一次性编码,我有 103 个特征(这是由于有 94 个唯一的提供者类型)。我创建了一个将逻辑回归分类器与 SMOTE 相结合的管道。
##########
#Use pipeline - combination of SMOTE and logistic regression model
# Define which resampling method and which ML model to use in the pipeline
resampling = SMOTE(random_state = 27, sampling_strategy = "minority")
model = LogisticRegression(solver='liblinear')
pipeline = Pipeline([('SMOTE', resampling), ('Logistic Regression', model)])
# Split your data X and y, into a training and a test set and fit the pipeline onto the training data
y = PartB_encoded['Is_fraud']
X = PartB_encoded.drop(['Is_fraud'], axis = 1)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=27)
pipeline.fit(X_train, y_train)
predicted = pipeline.predict(X_test)
print("Accuracy score: ", accuracy_score(y_true = y_test, y_pred = predicted))
print("Precision score: ", precision_score(y_true = y_test, y_pred=predicted))
print("Recall score: ", recall_score(y_true = y_test, y_pred= predicted))
# Obtain the results from the classification report and confusion matrix
print('Classifcation report:\n', classification_report(y_test, predicted))
conf_mat = confusion_matrix(y_true=y_test, y_pred=predicted)
print('Confusion matrix:\n', conf_mat)
这是我的输出:
Accuracy score: 0.9333130935552119
Precision score: 2.3716352424997034e-05
Recall score: 0.09090909090909091
Classification report:
precision recall f1-score support
False 1.00 0.93 0.97 632407
True 0.00 0.09 0.00 11
accuracy 0.93 632418
macro avg 0.50 0.51 0.48 632418
weighted avg 1.00 0.93 0.97 632418
Confusion matrix:
[[590243 42164]
[ 10 1]]
显然我的召回率和准确率极低,无法接受。如何提高召回率和准确率?我正在考虑进行欠采样,但如果我将负类从大约 100 万条记录中更改——> 14 条记录以匹配我的正类,我担心会删除太多数据。我也在考虑删除功能,但我不确定如何确定要删除哪些功能。
【问题讨论】:
-
虽然在数据集不平衡时可以使用一些技术,但我认为它不适用于您的情况。 100 万 vs 14:不仅数据不平衡,而且 14 太少,无法学习。你必须收集(甚至模拟自己)更多的欺诈数据
-
确实如@Wazaki 所说;请记住,机器学习不是魔法。
标签: python machine-learning classification imbalanced-data