Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么对于多个模型,我的精确度很高,但ROC AUC很低?_R_Model_Logistic Regression_Auc - Fatal编程技术网

为什么对于多个模型,我的精确度很高,但ROC AUC很低?

为什么对于多个模型,我的精确度很高,但ROC AUC很低?,r,model,logistic-regression,auc,R,Model,Logistic Regression,Auc,我的数据集大小是42542 x 14,我正在尝试建立不同的模型,如逻辑回归、KNN、RF、决策树,并比较精确度 我得到了每个模型的高精度但低ROC AUC 数据中约有85%的样本的目标变量为1,15%的样本的目标变量为0。为了处理这种不平衡,我试着取样,但结果还是一样的 glm的系数如下: glm(formula = loan_status ~ ., family = "binomial", data = lc_train) Deviance Residuals: Min

我的数据集大小是42542 x 14,我正在尝试建立不同的模型,如逻辑回归、KNN、RF、决策树,并比较精确度

我得到了每个模型的高精度但低ROC AUC

数据中约有85%的样本的目标变量为1,15%的样本的目标变量为0。为了处理这种不平衡,我试着取样,但结果还是一样的

glm的系数如下:

glm(formula = loan_status ~ ., family = "binomial", data = lc_train)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-2.7617   0.3131   0.4664   0.6129   1.6734  

Coefficients:
                                     Estimate Std. Error z value Pr(>|z|)    
(Intercept)                        -8.264e+00  8.338e-01  -9.911  < 2e-16 ***
annual_inc                          5.518e-01  3.748e-02  14.721  < 2e-16 ***
home_own                            4.938e-02  3.740e-02   1.320 0.186780    
inq_last_6mths1                    -2.094e-01  4.241e-02  -4.938 7.88e-07 ***
inq_last_6mths2-5                  -3.805e-01  4.187e-02  -9.087  < 2e-16 ***
inq_last_6mths6-10                 -9.993e-01  1.065e-01  -9.380  < 2e-16 ***
inq_last_6mths11-15                -1.448e+00  3.510e-01  -4.126 3.68e-05 ***
inq_last_6mths16-20                -2.323e+00  7.946e-01  -2.924 0.003457 ** 
inq_last_6mths21-25                -1.399e+01  1.970e+02  -0.071 0.943394    
inq_last_6mths26-30                 1.039e+01  1.384e+02   0.075 0.940161    
inq_last_6mths31-35                -1.973e+00  1.230e+00  -1.604 0.108767    
loan_amnt                          -1.838e-05  3.242e-06  -5.669 1.43e-08 ***
purposecredit_card                  3.286e-02  1.130e-01   0.291 0.771169    
purposedebt_consolidation          -1.406e-01  1.032e-01  -1.362 0.173108    
purposeeducational                 -3.591e-01  1.819e-01  -1.974 0.048350 *  
purposehome_improvement            -2.106e-01  1.189e-01  -1.771 0.076577 .  
purposehouse                       -3.327e-01  1.917e-01  -1.735 0.082718 .  
purposemajor_purchase              -7.310e-03  1.288e-01  -0.057 0.954732    
purposemedical                     -4.955e-01  1.530e-01  -3.238 0.001203 ** 
purposemoving                      -4.352e-01  1.636e-01  -2.661 0.007800 ** 
purposeother                       -3.858e-01  1.105e-01  -3.493 0.000478 ***
purposerenewable_energy            -8.150e-01  3.036e-01  -2.685 0.007263 ** 
purposesmall_business              -9.715e-01  1.186e-01  -8.191 2.60e-16 ***
purposevacation                    -4.169e-01  2.012e-01  -2.072 0.038294 *  
purposewedding                      3.909e-02  1.557e-01   0.251 0.801751    
open_acc                           -1.408e-04  4.147e-03  -0.034 0.972923    
gradeB                             -4.377e-01  6.991e-02  -6.261 3.83e-10 ***
gradeC                             -5.858e-01  8.340e-02  -7.024 2.15e-12 ***
gradeD                             -7.636e-01  9.558e-02  -7.990 1.35e-15 ***
gradeE                             -7.832e-01  1.115e-01  -7.026 2.13e-12 ***
gradeF                             -9.730e-01  1.325e-01  -7.341 2.11e-13 ***
gradeG                             -1.031e+00  1.632e-01  -6.318 2.65e-10 ***
verification_statusSource Verified  6.340e-02  4.435e-02   1.429 0.152898    
verification_statusVerified         6.864e-02  4.400e-02   1.560 0.118739    
dti                                -4.683e-03  2.791e-03  -1.678 0.093373 .  
fico_range_low                      6.705e-03  9.292e-04   7.216 5.34e-13 ***
term                                5.773e-01  4.499e-02  12.833  < 2e-16 ***
emp_length2-4 years                 6.341e-02  4.911e-02   1.291 0.196664    
emp_length5-9 years                -3.136e-02  5.135e-02  -0.611 0.541355    
emp_length10+ years                -2.538e-01  5.185e-02  -4.895 9.82e-07 ***
delinq_2yrs2+                       5.919e-02  9.701e-02   0.610 0.541754    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 25339  on 29779  degrees of freedom
Residual deviance: 23265  on 29739  degrees of freedom
AIC: 23347

Number of Fisher Scoring iterations: 10
Confusion Matrix and Statistics

          Reference
Prediction     0     1
         0    32    40
         1  1902 10788

               Accuracy : 0.8478         
                 95% CI : (0.8415, 0.854)
    No Information Rate : 0.8485         
    P-Value [Acc > NIR] : 0.5842         

                  Kappa : 0.0213         

 Mcnemar's Test P-Value : <2e-16         

            Sensitivity : 0.016546       
            Specificity : 0.996306       
         Pos Pred Value : 0.444444       
         Neg Pred Value : 0.850118       
             Prevalence : 0.151544       
         Detection Rate : 0.002507       
   Detection Prevalence : 0.005642       
      Balanced Accuracy : 0.506426       

       'Positive' Class : 0    
glm(公式=贷款状态~,family=“二项式”,数据=信用证列车)
偏差残差:
最小1季度中值3季度最大值
-2.7617   0.3131   0.4664   0.6129   1.6734  
系数:
估计标准误差z值Pr(>z)
(截距)-8.264e+00 8.338e-01-9.911<2e-16***
年鉴公司5.518e-01 3.748e-02 14.721<2e-16***
home_own 4.938e-02 3.740e-02 1.320 0.186780
inq_last_6mths1-2.094e-01 4.241e-02-4.938 7.88e-07***
inq_last_6mths2-5-3.805e-01 4.187e-02-9.087<2e-16***
inq_last_6mths6-10-9.993e-01 1.065e-01-9.380<2e-16***
inq_last_6mths11-15-1.448e+00 3.510e-01-4.126 3.68e-05***
inq_last_6mths16-20-2.323e+00 7.946e-01-2.924 0.003457**
inq_last_6mths21-25-1.399e+01 1.970e+02-0.071 0.943394
inq_last_6mths26-30 1.039e+01 1.384e+02 0.075 0.940161
最后6个月31-35-1.973e+001.230e+00-1.6040.108767
贷款金额-1.838e-05 3.242e-06-5.669 1.43e-08***
目的信用卡3.286e-02 1.130e-01 0.291 0.771169
目的债务合并-1.406e-01 1.032e-01-1.362 0.173108
教育目的-3.591e-01 1.819e-01-1.974 0.048350*
目的家庭改善-2.106e-01 1.189e-01-1.771 0.076577。
目的地-3.327e-01 1.917e-01-1.7350.082718。
目的主要采购-7.310e-03 1.288e-01-0.057 0.954732
目的医学-4.955e-01 1.530e-01-3.238 0.001203**
目的-4.352e-01 1.636e-01-2.661 0.007800**
目的其他-3.858e-01 1.105e-01-3.493 0.000478***
目的可再生能源-8.150e-01 3.036e-01-2.685 0.007263**
目的小型企业-9.715e-01 1.186e-01-8.191 2.60e-16***
目的-4.169e-01 2.012e-01-2.072 0.038294*
目的婚礼3.909e-02 1.557e-01 0.251 0.801751
打开附件-1.408e-04 4.147e-03-0.034 0.972923
B级-4.377e-01 6.991e-02-6.261 3.83e-10***
C级-5.858e-01 8.340e-02-7.024 2.15e-12***
等级-7.636e-01 9.558e-02-7.990 1.35e-15***
等级E-7.832e-01 1.115e-01-7.026 2.13e-12***
F级-9.730e-01 1.325e-01-7.341 2.11e-13***
G级-1.031e+00 1.632e-01-6.318 2.65e-10***
验证\u状态来源验证6.340e-02 4.435e-02 1.429 0.152898
验证状态验证6.864e-02 4.400e-02 1.560 0.118739
dti-4.683e-03 2.791e-03-1.678 0.093373。
fico_范围_低6.705e-03 9.292e-04 7.216 5.34e-13***
术语5.773e-01 4.499e-02 12.833<2e-16***
emp_长度2-4年6.341e-02 4.911e-02 1.291 0.196664
emp_长度5-9年-3.136e-02 5.135e-02-0.611 0.541355
emp_长度10+年-2.538e-01 5.185e-02-4.895 9.82e-07***
delinq_2yrs2+5.919e-02 9.701e-02 0.610 0.541754
---
签名。代码:0'***'0.001'***'0.01'*'0.05'.'0.1''1
(二项式族的离散参数取为1)
零偏差:29779自由度上的25339
剩余偏差:29739自由度上的23265
工商行政管理局:23347
Fisher评分迭代次数:10
LR的混淆矩阵如下所示:

glm(formula = loan_status ~ ., family = "binomial", data = lc_train)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-2.7617   0.3131   0.4664   0.6129   1.6734  

Coefficients:
                                     Estimate Std. Error z value Pr(>|z|)    
(Intercept)                        -8.264e+00  8.338e-01  -9.911  < 2e-16 ***
annual_inc                          5.518e-01  3.748e-02  14.721  < 2e-16 ***
home_own                            4.938e-02  3.740e-02   1.320 0.186780    
inq_last_6mths1                    -2.094e-01  4.241e-02  -4.938 7.88e-07 ***
inq_last_6mths2-5                  -3.805e-01  4.187e-02  -9.087  < 2e-16 ***
inq_last_6mths6-10                 -9.993e-01  1.065e-01  -9.380  < 2e-16 ***
inq_last_6mths11-15                -1.448e+00  3.510e-01  -4.126 3.68e-05 ***
inq_last_6mths16-20                -2.323e+00  7.946e-01  -2.924 0.003457 ** 
inq_last_6mths21-25                -1.399e+01  1.970e+02  -0.071 0.943394    
inq_last_6mths26-30                 1.039e+01  1.384e+02   0.075 0.940161    
inq_last_6mths31-35                -1.973e+00  1.230e+00  -1.604 0.108767    
loan_amnt                          -1.838e-05  3.242e-06  -5.669 1.43e-08 ***
purposecredit_card                  3.286e-02  1.130e-01   0.291 0.771169    
purposedebt_consolidation          -1.406e-01  1.032e-01  -1.362 0.173108    
purposeeducational                 -3.591e-01  1.819e-01  -1.974 0.048350 *  
purposehome_improvement            -2.106e-01  1.189e-01  -1.771 0.076577 .  
purposehouse                       -3.327e-01  1.917e-01  -1.735 0.082718 .  
purposemajor_purchase              -7.310e-03  1.288e-01  -0.057 0.954732    
purposemedical                     -4.955e-01  1.530e-01  -3.238 0.001203 ** 
purposemoving                      -4.352e-01  1.636e-01  -2.661 0.007800 ** 
purposeother                       -3.858e-01  1.105e-01  -3.493 0.000478 ***
purposerenewable_energy            -8.150e-01  3.036e-01  -2.685 0.007263 ** 
purposesmall_business              -9.715e-01  1.186e-01  -8.191 2.60e-16 ***
purposevacation                    -4.169e-01  2.012e-01  -2.072 0.038294 *  
purposewedding                      3.909e-02  1.557e-01   0.251 0.801751    
open_acc                           -1.408e-04  4.147e-03  -0.034 0.972923    
gradeB                             -4.377e-01  6.991e-02  -6.261 3.83e-10 ***
gradeC                             -5.858e-01  8.340e-02  -7.024 2.15e-12 ***
gradeD                             -7.636e-01  9.558e-02  -7.990 1.35e-15 ***
gradeE                             -7.832e-01  1.115e-01  -7.026 2.13e-12 ***
gradeF                             -9.730e-01  1.325e-01  -7.341 2.11e-13 ***
gradeG                             -1.031e+00  1.632e-01  -6.318 2.65e-10 ***
verification_statusSource Verified  6.340e-02  4.435e-02   1.429 0.152898    
verification_statusVerified         6.864e-02  4.400e-02   1.560 0.118739    
dti                                -4.683e-03  2.791e-03  -1.678 0.093373 .  
fico_range_low                      6.705e-03  9.292e-04   7.216 5.34e-13 ***
term                                5.773e-01  4.499e-02  12.833  < 2e-16 ***
emp_length2-4 years                 6.341e-02  4.911e-02   1.291 0.196664    
emp_length5-9 years                -3.136e-02  5.135e-02  -0.611 0.541355    
emp_length10+ years                -2.538e-01  5.185e-02  -4.895 9.82e-07 ***
delinq_2yrs2+                       5.919e-02  9.701e-02   0.610 0.541754    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 25339  on 29779  degrees of freedom
Residual deviance: 23265  on 29739  degrees of freedom
AIC: 23347

Number of Fisher Scoring iterations: 10
Confusion Matrix and Statistics

          Reference
Prediction     0     1
         0    32    40
         1  1902 10788

               Accuracy : 0.8478         
                 95% CI : (0.8415, 0.854)
    No Information Rate : 0.8485         
    P-Value [Acc > NIR] : 0.5842         

                  Kappa : 0.0213         

 Mcnemar's Test P-Value : <2e-16         

            Sensitivity : 0.016546       
            Specificity : 0.996306       
         Pos Pred Value : 0.444444       
         Neg Pred Value : 0.850118       
             Prevalence : 0.151544       
         Detection Rate : 0.002507       
   Detection Prevalence : 0.005642       
      Balanced Accuracy : 0.506426       

       'Positive' Class : 0    
混淆矩阵与统计
参考文献
预测0 1
0    32    40
1  1902 10788
准确度:0.8478
95%可信区间:(0.8415,0.854)
无信息率:0.8485
P值[Acc>NIR]:0.5842
卡帕值:0.0213

Mcnemar的测试P值:

如果有人提出混淆矩阵并谈论低ROC AUC,通常意味着他/她已将预测/概率转换为0和1,而ROC AUC公式并不要求这样做-它对原始概率有效,从而产生更好的结果。如果目标是获得最佳AUC值,最好在培训时将其设置为评估指标,这样可以获得比其他指标更好的结果。

这似乎是关于数据建模的问题,而不是特定的编程问题。这些问题属于像or这样的站点,而不是堆栈溢出。嗨,sneha,我建议你画一些这样的图,这样你就可以理解很容易获得100%的准确度,困难的是保持平衡为什么你认为0.85是好/高准确度,如果不使用任何ML就可以获得相同的值,只是预测所有情况下的1?换句话说,
loan_status~1
似乎和你复杂的模型一样好。它是不平衡的,你的模型试图预测一切都是1,因为在混乱矩阵中,(1902+10788)/(10788+40+32+1902)=0.99的预测是1,这比你在数据中看到的还要多;2.kappa值太低,表示