1

我使用逻辑回归来获得 y 的一些概率,我做了以下操作:

fit.model <- glm (y~ x1 +x2 , data = mydata, family=binomial)  
pred_model<- plogis(predict(fit.model, mydata))

现在,我想使用 0.5 的截止值将概率分类为是或否
我试过这个,但可能不起作用

class <- ifelse(pred_model>0.5, "yes" , "no" )       

有什么建议么?

4

1 回答 1

1

这应该工作:

class <- factor(ifelse(pred_model>0.5, "yes", "no"), c("yes", "no"))
于 2013-06-25T12:32:46.183 回答