I am training a classification "nnet" model via the "tidymodels" packages.
When using the predict function I get differences between the "raw" and "prob" types.
#install.packages("nnet") #v7.3-17
#install.packages("tidymodels") #v0.1.4
library(tidymodels)
n = 1000
set.seed(123)
df = tibble(var_1 = runif(n),
var_2 = runif(n),
var_3 = rnorm(n),
label = factor(sample(c("accept","reject"), n, replace = TRUE)))
df_split = rsample::initial_split(df, prop = (3/4))
mlp_recipe <- recipe(label ~ ., data = df)
model_spec = mlp() %>%
set_mode("classification") %>%
set_engine("nnet")
model_workflow = workflow() %>%
add_recipe(mlp_recipe) %>%
add_model(model_spec)
model_fit <- model_workflow %>%
fit(data = training(df_split))
#difference in predictions
prob_pred = predict(model_fit, training(df_split), type = 'prob') %>% #notice type = "prob
tibble() %>%
select(1)%>%
pull()
raw_pred = predict(model_fit, training(df_split), type = 'raw') %>% #notice type ="raw"
as.vector()
bind_cols(prob_pred = prob_pred, raw_pred = raw_pred) %>%
mutate(sum = prob_pred + raw_pred) %>% #the sum doesnt add to 1 discarding that I am looking at the 1-p case.
head()