Type parameter of the predict() function

r

Solution

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"

Problem

What is the difference between `type="class"` and `type="response"` in the `predict` function? For instance between: ``` predict(modelName, newdata=testData, type = "class") ``` and ``` predict(modelName, newdata=testData, type = "response") ```

Original source