tidyclust
tidyclust copied to clipboard
Find a way to have `finalize_workflow()` be more generic
trafficstars
This change might have to happen in workflows
library(tidymodels)
library(celery)
#>
#> Attaching package: 'celery'
#> The following object is masked from 'package:parsnip':
#>
#> prepare_data
rec_spec <- recipe(~., data = mtcars)
kmeans_spec <- k_means(k = tune())
wf_spec <- workflow(rec_spec, kmeans_spec)
wf_spec %>% finalize_workflow(tibble(k = 3))
#> Error in `finalize_model()`:
#> ! `x` should be a parsnip model specification.
Created on 2022-05-12 by the reprex package (v2.0.1)
This could be handled by setting letting finalize_model() be a generic. This way it is automatically handled in finalize_workflow()
Note: We have tidyclust specific function finalize_workflow_tidyclust(). This should either be referenced in the tune function or we move over to use refactor it
library(tidymodels)
library(tidyclust)
#>
#> Attaching package: 'tidyclust'
#> The following object is masked from 'package:parsnip':
#>
#> prepare_data
rec_spec <- recipe(~., data = mtcars)
kmeans_spec <- k_means(k = tune())
wf_spec <- workflow(rec_spec, kmeans_spec)
wf_spec %>% finalize_workflow_tidyclust(tibble(k = 3))
#> ══ Workflow ════════════════════════════════════════════════════════════════════
#> Preprocessor: Recipe
#> Model: k_means()
#>
#> ── Preprocessor ────────────────────────────────────────────────────────────────
#> 0 Recipe Steps
#>
#> ── Model ───────────────────────────────────────────────────────────────────────
#> K Means Cluster Specification (partition)
#>
#> Main Arguments:
#> k = 3
#>
#> Computational engine: stats
Created on 2022-07-10 by the reprex package (v2.0.1)