[英]R multiclass/multinomial classification ROC using multiclass.roc (Package ‘pROC’)
I am having difficulties understanding how the multiclass.roc parameters should look like. 我很难理解multiclass.roc参数应该是什么样子。 Here a snapshot of my data:
这是我的数据的快照:
> head(testing.logist$cut.rank)
[1] 3 3 3 3 1 3
Levels: 1 2 3
> head(mnm.predict.test.probs)
1 2 3
9 1.013755e-04 3.713862e-02 0.96276001
10 1.904435e-11 3.153587e-02 0.96846413
12 6.445101e-23 1.119782e-11 1.00000000
13 1.238355e-04 2.882145e-02 0.97105472
22 9.027254e-01 7.259787e-07 0.09727389
26 1.365667e-01 4.034372e-01 0.45999610
>
I tried calling multiclass.roc with: 我尝试使用以下方法调用multiclass.roc:
multiclass.roc(
response=testing.logist$cut.rank,
predictor=mnm.predict.test.probs,
formula=response~predictor
)
but naturally I get an error: 但自然我得到一个错误:
Error in roc.default(response, predictor, levels = X, percent = percent, :
Predictor must be numeric or ordered.
When it's a binary classification problem I know that 'predictor' should contain probabilities (one per observation). 当它是二元分类问题时,我知道“预测器”应该包含概率(每个观察一个)。 However, in my case, I have 3 classes, so my predictor is a list of rows that each have 3 columns (or a sublist of 3 values) correspond to the probability for each class.
但是,在我的情况下,我有3个类,所以我的预测器是一个行列表,每个行有3列(或3个值的子列表)对应于每个类的概率。 Does anyone know how should my 'predictor' should look like rather than what it's currently look like ?
有谁知道我的“预测器”应该是什么样子而不是它现在的样子?
The pROC package is not really designed to handle this case where you get multiple predictions (as probabilities for each class). pROC包并不是真正设计用于处理这种情况,您可以获得多个预测(作为每个类的概率)。 Typically you would assess your P(class = 1)
通常你会评估你的P(等级= 1)
multiclass.roc(
response=testing.logist$cut.rank,
predictor=mnm.predict.test.probs[,1])
And then do it again with P(class = 2) and P(class = 3). 然后使用P(class = 2)和P(class = 3)再次执行此操作。 Or better, determine the most likely class:
或者更好,确定最可能的类:
predicted.class <- apply(mnm.predict.test.probs, 1, which.max)
multiclass.roc(
response=testing.logist$cut.rank,
predictor=predicted.class)
Consider multiclass.roc
as a toy that can sometimes be helpful but most likely won't really fit your needs. 将
multiclass.roc
视为一种有时可能有用的玩具,但很可能不太适合您的需求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.