tidymodels / rules

parsnip extension for rule-based models
https://rules.tidymodels.org
Other
40 stars 4 forks source link

change C5_rules fit object class #58

Closed topepo closed 2 years ago

topepo commented 2 years ago

Closes #49

We were setting an extra class that was not needed and that class was the same as the model specification name.

simonpcouch commented 2 years ago

A quick reprex mirroring Julia's on the original issue with this branch's changes to help walk myself through what changed:

library(tidymodels)
library(rules)
#> 
#> Attaching package: 'rules'
#> The following object is masked from 'package:dials':
#> 
#>     max_rules

data(two_class_dat)

folds <- vfold_cv(two_class_dat, v = 3)

spec <- C5_rules(trees = tune()) %>% 
  set_engine("C5.0")

class(spec)
#> [1] "C5_rules"   "model_spec"

# quick detour -  model _fit_ class:
# (first class used to be "_C5_rules")
class(
  spec %>% 
    update(trees = 5) %>%
    fit(Class ~ ., data = two_class_dat)
)
#> [1] "_C5.0"     "model_fit"

# back to prev reprex:
tuned <- spec %>%
  tune_grid(Class ~ ., resamples = folds, grid = 20)

# tuning works!
autoplot(tuned)

Created on 2022-06-01 by the reprex package (v2.0.1)

github-actions[bot] commented 2 years ago

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.