Closed
Description
You get a nice text when you print the model specification.
This isn't a parsnip issue as far as I can tell since you get a nice warning if you try with just a parsnip object.
library(tidymodels)
model_recipe <- recipe(Species ~ ., data = iris)
# Create a workflow
model_final <- naive_Bayes() |>
set_mode("classification") |>
set_engine("klaR")
train_fit <- fit(model_final, Species ~ ., data = iris)
#> Error in `fit()`:
#> ! parsnip could not locate an implementation for `naive_Bayes`
#> classification model specifications using the `klaR` engine.
#> ℹ The parsnip extension package discrim implements support for this
#> specification.
#> ℹ Please install (if needed) and load to continue.
#> Backtrace:
#> ▆
#> 1. ├─generics::fit(model_final, Species ~ ., data = iris)
#> 2. └─parsnip::fit.model_spec(model_final, Species ~ ., data = iris)
#> 3. └─parsnip:::prompt_missing_implementation(...) at parsnip/R/fit.R:121:6
#> 4. └─cli (local) prompt(c(msg, ""), ...) at parsnip/R/misc.R:201:2
#> 5. └─rlang::abort(...)
Reprex
library(tidymodels)
model_recipe <- recipe(Species ~ ., data = iris)
# Create a workflow
model_final <- naive_Bayes() |>
set_mode("classification") |>
set_engine("klaR")
model_final_wf <- workflow() |>
add_recipe(model_recipe) |>
add_model(model_final)
train_fit <- fit(model_final_wf, data = iris)
#> Error in `fit_xy()`:
#> ! data.frame_ is unknown.
#> Backtrace:
#> ▆
#> 1. ├─generics::fit(model_final_wf, data = iris)
#> 2. └─workflows:::fit.workflow(model_final_wf, data = iris)
#> 3. └─workflows::.fit_model(workflow, control)
#> 4. ├─generics::fit(action_model, workflow = workflow, control = control)
#> 5. └─workflows:::fit.action_model(...)
#> 6. └─workflows:::fit_from_xy(spec, mold, case_weights, control_parsnip)
#> 7. ├─generics::fit_xy(...)
#> 8. └─parsnip::fit_xy.model_spec(...)
#> 9. └─rlang::abort(glue::glue("{interfaces} is unknown.")) at parsnip/R/fit.R:292:4
model_final_wf
#> ══ Workflow ════════════════════════════════════════════════════════════════════
#> Preprocessor: Recipe
#> Model: naive_Bayes()
#>
#> ── Preprocessor ────────────────────────────────────────────────────────────────
#> 0 Recipe Steps
#>
#> ── Model ───────────────────────────────────────────────────────────────────────
#> ! parsnip could not locate an implementation for `naive_Bayes` classification
#> model specifications using the `klaR` engine.
#> ℹ The parsnip extension package discrim implements support for this
#> specification.
#> ℹ Please install (if needed) and load to continue.
#> Naive Bayes Model Specification (classification)
#>
#> Computational engine: klaR
library(discrim)
#>
#> Attaching package: 'discrim'
#> The following object is masked from 'package:dials':
#>
#> smoothness
train_fit <- fit(model_final_wf, data = iris)
train_fit
#> ══ Workflow [trained] ══════════════════════════════════════════════════════════
#> Preprocessor: Recipe
#> Model: naive_Bayes()
#>
#> ── Preprocessor ────────────────────────────────────────────────────────────────
#> 0 Recipe Steps
#>
#> ── Model ───────────────────────────────────────────────────────────────────────
#> $apriori
#> grouping
#> setosa versicolor virginica
#> 0.3333333 0.3333333 0.3333333
#>
#> $tables
#> $tables$Sepal.Length
#> $tables$Sepal.Length$setosa
#>
#> Call:
#> density.default(x = xx)
#>
#> Data: xx (50 obs.); Bandwidth 'bw' = 0.1229
#>
#> x y
#> Min. :3.931 Min. :0.0008217
#> 1st Qu.:4.491 1st Qu.:0.1008903
#> Median :5.050 Median :0.3796642
#> Mean :5.050 Mean :0.4465351
#> 3rd Qu.:5.609 3rd Qu.:0.6865548
#> Max. :6.169 Max. :1.2397687
#>
#> $tables$Sepal.Length$versicolor
#>
#> Call:
#> density.default(x = xx)
#>
#> Data: xx (50 obs.); Bandwidth 'bw' = 0.2124
#>
#> x y
#> Min. :4.263 Min. :0.0005386
#> 1st Qu.:5.106 1st Qu.:0.0508068
#> Median :5.950 Median :0.2503411
#> Mean :5.950 Mean :0.2960165
#> 3rd Qu.:6.794 3rd Qu.:0.5117124
#> Max. :7.637 Max. :0.7319843
#>
#> $tables$Sepal.Length$virginica
#>
#> Call:
#> density.default(x = xx)
#>
#> Data: xx (50 obs.); Bandwidth 'bw' = 0.2073
#>
#> x y
#> Min. :4.278 Min. :0.0004334
#> 1st Qu.:5.339 1st Qu.:0.0304136
#> Median :6.400 Median :0.2147562
#> Mean :6.400 Mean :0.2353874
#> 3rd Qu.:7.461 3rd Qu.:0.3752514
#>
#> ...
#> and 312 more lines.
Created on 2022-10-25 with reprex v2.0.2