[R] Strange error with ROCR

Tobias Sing tobias.sing at gmail.com
Tue Aug 4 20:49:39 CEST 2009


> Is the "probability of the true label" the best prediction to feed to
> the ROCR package, or is it better to use the "decision.value"

Since AFAIK they are related by a monotonous transformation, both
approaches should lead to the same ROC curve, shouldn't they? (not
tested)

On Tue, Aug 4, 2009 at 8:14 PM, Noah Silverman<noah at smartmediacorp.com> wrote:
> Good point.  I'm not sure how I missed that.
>
> This does lead to an additional question:
>
> Is the "probability of the true label" the best prediction to feed to
> the ROCR package, or is it better to use the "decision.value"
>
> Anybody have any experience on this one?
>
> Thanks!
>
> -N
>
> On 8/4/09 3:28 AM, Christian Schulz wrote:
>> Hi,
>>
>> you need  the score value , have a look at ?svm.predict and in the
>> ROCR example.
>>
>> traindata <- as.data.frame(matrix(runif(1000),ncol=10))
>> trainlabels <-
>> as.factor(sample(c("win","lose"),nrow(data),replace=T,prob=c(0.5,0.5)))
>>
>> model <- svm(traindata,trainlabels, type="C-classification",
>> kernel="radial", cost=10,
>> class.weights=c("win"=3,"lose"=1), scale=FALSE, probability = TRUE)
>>
>> prediction <- predict(model, traindata, decision.values = TRUE,
>> probability = TRUE)
>> probs <-  attr(prediction, "probabilities")[,1]
>> pred <- prediction(probs,trainlabels)
>>
>> HTH Christian
>>
>>> Hello,
>>>
>>> I've come across a strange error...
>>>
>>>
>>> Here is what happens:
>>>
>>> model <- svm(traindata,trainlabels, type="C-classification",
>>> kernel="radial", cost=10,  class.weights=c("win"=3,"lose"=1),
>>> scale=FALSE, probability = TRUE)
>>> predictions <- predict(model, traindata)
>>> pred <- prediction(predictions, trainlabels)
>>>
>>>
>>> This returns an error:
>>> Error in prediction(predictions, trainlabels) :
>>>    Format of predictions is invalid.
>>>
>>> Yet my predictions is just a matrix of predicted labels.  Nothing
>>> fancy.  (In fact, my step follow the exact example on the ROCR
>>> homepage.)
>>>
>>> A search through google for "Format of predictions is invalid"
>>> returns zero results.
>>>
>>> Can anyone suggest how I might fix this problem?
>>>
>>> Thank You,
>>>
>>>
>>>
>>>
>>>
>>>     [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list