multinom models

if (requireNamespace("nnet", quietly = TRUE)) {
  library(tidypredict)
  library(nnet)
  library(dplyr)
  eval_code <- TRUE
} else {
  eval_code <- FALSE
}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  eval = eval_code
)

| Function |Works| |---------------------------------------------------------------|-----| |tidypredict_fit(), tidypredict_sql(), parse_model() | ✔ | |tidypredict_to_column() | ✗ | |tidypredict_test() | ✗ | |tidypredict_interval(), tidypredict_sql_interval() | ✗ | |parsnip | ✔ |

nnet::multinom() fits multinomial log-linear models. Because these models predict one probability per outcome class, tidypredict_fit() returns a named list of expressions, one for each class, rather than a single expression. The expressions implement the softmax over the per-class linear predictors, with the first level of the outcome acting as the reference class.

Since the output is a list, tidypredict_to_column() and tidypredict_test() are not supported.

tidypredict_ functions

library(nnet)

model <- multinom(Species ~ ., data = iris, trace = FALSE)

iris %>% mutate(!!!tidypredict_fit(model)) %>% glimpse() ```

parsnip

parsnip fitted models are also supported by tidypredict:

library(parsnip)

p_model <- multinom_reg() %>%
  set_engine("nnet") %>%
  fit(Species ~ ., data = iris)
tidypredict_fit(p_model)[["virginica"]]

Parse model spec

Here is an example of the model spec:

pm <- parse_model(model)
str(pm, 2)


Try the tidypredict package in your browser

Any scripts or data that you put into this service are public.

tidypredict documentation built on Oct. 18, 2026, 5:06 p.m.