[英]In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
I am trying to use AUC package
in R to get specificity. 我试图在R中使用
AUC package
来获得特异性。 However I is does not work. 但是我是行不通的。 I got this Warning messages:
我收到此警告消息:
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
2: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
3: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
This the command I used 这是我使用的命令
specificity(P_hat0[,3], DNew$outcome[DNew$visitmse==0])
$cutoffs
[1] 1.00000000 1.00000000 0.97727273 0.95454545 0.93181818 0.90909091
[7] 0.88636364 0.86363636 0.84090909 0.81818182 0.79545455 0.77272727
[13] 0.75000000 0.72727273 0.70454545 0.68181818 0.65909091 0.63636364
[19] 0.61363636 0.59090909 0.56818182 0.54545455 0.52272727 0.50000000
[25] 0.47727273 0.45454545 0.43181818 0.40909091 0.38636364 0.36363636
[31] 0.34090909 0.31818182 0.29545455 0.27272727 0.25000000 0.22727273
[37] 0.20454545 0.18181818 0.15909091 0.13636364 0.11363636 0.09090909
[43] 0.06818182 0.04545455 0.02272727 0.00000000
$measure
[1] NaN NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[20] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[39] NA NA NA NA NA NA NA 0
attr(,"class")
[1] "AUC" "specificity"
Warning messages:
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
2: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
3: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
The predictions and the labels are: 预测和标签为:
DNew$outcome
[1] 1 1 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0
[38] 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0 0 0
[75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0
[112] 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1
> P_hat0[,3]
[1] 0.1676221 0.5666334 0.5520391 0.3845506 0.5369669 0.4210906 0.6804216
[8] 0.6000813 0.4258318 0.5299374 0.5847862 0.6261463 0.6789501 0.5840120
[15] 0.5413866 0.6426050 0.2822611 0.6945680 0.5959189 0.5231346 0.7052698
[22] 0.5514049 0.7207629 0.6405132 0.1620128 0.7349927 0.5567275 0.6423642
[29] 0.6075940 0.8023867 0.5030725 0.5373831 0.5846428 0.6648525 0.5833133
[36] 0.4888089 0.6430406 0.5713645 0.5366524 0.6193379 0.6407926 0.6624230
[43] 0.6429118 0.6719707
Could you please tell me why the measures are NAN or NA
? 您能告诉我为什么采取
NAN or NA
措施吗? Thanks 谢谢
Based on the description from ?specificity
, the labels
would be factor
class. 根据对“
?specificity
的描述, labels
将是factor
类。
labels: A factor of observed class labels (responses) with the only allowed values {0,1}.
标签:观察到的类别标签(响应)的因子,其唯一允许值为{0,1}。
Using the 'churn' data from AUC
having factor
'labels', specificity
doesn't return any warnings. 使用来自
AUC
具有factor
“标签”的“流失”数据, specificity
不会返回任何警告。
library(AUC)
data(churn)
res1 <- specificity(churn$predictions,churn$labels)
If I change 'labels' to numeric
class 如果我将“标签”更改为
numeric
类
res2 <- specificity(churn$predictions,as.numeric(churn$labels))
#Warning messages:
#1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
#2: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
#3: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
So, probably, changing the OP's 'outcome' column to 'factor' may work (assuming that the lengths are the same) 因此,可能将OP的“结果”列更改为“因子”可能会起作用(假设长度相同)
specificity(P_hat0[,3], factor(DNew$outcome[DNew$visitmse==0]))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.