knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(tidypredict) library(earth) library(dplyr)
| Function |Works|
|---------------------------------------------------------------|-----|
|tidypredict_fit()
, tidypredict_sql()
, parse_model()
| ✔ |
|tidypredict_to_column()
| ✔ |
|tidypredict_test()
| ✔ |
|tidypredict_interval()
, tidypredict_sql_interval()
| ✗ |
|parsnip
| ✔ |
tidypredict_
functionslibrary(earth) data("etitanic", package = "earth") model <- earth(age ~ sibsp + parch, data = etitanic, degree = 3)
Create the R formula
r
tidypredict_fit(model)
SQL output example
r
tidypredict_sql(model, dbplyr::simulate_odbc())
Add the prediction to the original table ```r library(dplyr)
etitanic %>% tidypredict_to_column(model) %>% glimpse() ```
Confirm that tidypredict
results match to the model's predict()
results
r
tidypredict_test(model, etitanic)
tidypredict
supports the glm
argument as well:
model <- earth(survived ~ ., data = etitanic, glm = list(family = binomial), degree = 2) tidypredict_fit(model)
The spec sets the is_glm
entry to 1, as well as the family
and link
entries.
str(parse_model(model), 2)
parsnip
fitted models are also supported by tidypredict
:
library(parsnip) p_model <- mars(mode = "regression", prod_degree = 3) %>% set_engine("earth") %>% fit(age ~ sibsp + parch, data = etitanic) tidypredict_fit(p_model)
Here is an example of the model spec:
pm <- parse_model(model) str(pm, 2)
str(pm$terms[1:2])
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.