Type parameter of the predict() function

后端 未结 3 1549
青春惊慌失措
青春惊慌失措 2021-02-05 08:29

What is the difference between type=\"class\" and type=\"response\" in the predict function?

For instance between:



        
3条回答
  •  萌比男神i
    2021-02-05 08:53

    Response gives you the numerical result while class gives you the label assigned to that value.

    Response lets you to determine your threshold. For instance,

    glm.fit = glm(Direction~., data=data, family = binomial, subset = train)
    glm.probs = predict(glm.fit, test, type = "response")
    

    In glm.probs we have some numerical values between 0 and 1. Now we can determine the threshold value, let's say 0.6. Direction has two possible outcomes, up or down.

    glm.pred = rep("Down",length(test))
    glm.pred[glm.probs>.6] = "Up"
    

提交回复
热议问题