I have an array of probability over a classification
post <- c(0.73,0.69,0.44,0.55,0.67,0.47,0.08,0.15,0.45,0.35)
and I want to retrieve the predicted class. right now I use
predicted <- function(post) {
function(threshold) {plyr::aaply(post, 1,
function(x) {if(x >= threshold) '+' else '-'})}}
but that seems like something R would have a syntax for.
Is there some indexing expression that would be more direct ?
pred <- c("-", "+")[1+(post > 0.5)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With