【问题标题】:How to increase false positives and reduce false negatives in a logistic regression?如何在逻辑回归中增加误报并减少误报?
【发布时间】:2019-06-18 11:27:00
【问题描述】:

我在记录链接问题中得到的结果是将更多的值分类为误报而不是误报。有没有办法平衡这些?

# Initialize the classifier

    logreg = rl.LogisticRegressionClassifier()

# Train the classifier

    logreg.fit(golden_pairs, golden_matches_index)
    print ("Intercept: ", logreg.intercept)
    print ("Coefficients: ", logreg.coefficients)

# Predict the match status for all record pairs
result_logreg = logreg.predict(test_pairs[columns_to_keep])

len(result_logreg)

#true_links = features_complete_new_index[features_complete_new_index['evaluation'] == True].index
true_links = test_pairs[test_pairs['evaluation'] == True].index


print("confusion matrix of Logistic Regression ",rl.confusion_matrix(true_links, result_logreg, len(test_pairs)), "False positives ", rl.false_positives(true_links, result_logreg), "False negatives ", rl.false_negatives(true_links, result_logreg))


The output is Intercept:  -6.974042394356818
Coefficients:  [-0.07818545  7.83113994  0.96939354 -6.97404239  1.65737031  0.694744  ]
confusion matrix of Logistic Regression  [[   5915    2576]
 [   1075 7167134]] False positives  1075 False negatives  2576
F-Score of Log Regr  0.7641625218009173

【问题讨论】:

标签: python pandas logistic-regression


【解决方案1】:

您可以随时调整分类器,但平衡是什么意思? FP和FN更有趣,哪个预测更伤你?

FN(假阴性)预测是原始预测为真且未被您的分类器识别的预测。因此,如果您尝试检测欺诈检测,而您的 True 值为欺诈,那么假阴性将是一个真正的问题,因为这种欺诈不会被识别。

这是一本充满答案的书,我们可以告诉你。尝试调整这行代码:logreg = rl.LogisticRegressionClassifier()看看变化如何

【讨论】:

  • 如果您解释了如何更改特定的代码行,将会有所帮助。
  • scikit-learn.org/stable/modules/generated/…这是你的playsheet,例如你可以设置logreg= rl.LogisticRegressionClassifier(penalty=’l1’)
  • 您在哪里发现 OP 使用了 scikitlearn 实现? scikitlearn 逻辑回归称为“LogisticRegression”,因此您的示例似乎无效并且与您提供的链接不一致。
猜你喜欢
  • 1970-01-01
  • 2015-12-16
  • 2021-04-14
  • 2016-09-17
  • 2020-07-16
  • 1970-01-01
  • 2016-02-21
  • 2019-03-05
  • 1970-01-01
相关资源
最近更新 更多