Giter Site home page Giter Site logo

rules's Introduction

rules

Lifecycle: experimental R-CMD-check Codecov test coverage CRAN status

Introduction

rules is a parsnip extension package with model definitions for rule-based models, including:

  • cubist models that have discrete rule sets that contain linear models with an ensemble method similar to boosting
  • classification rules where a ruleset is derived from an initial tree fit
  • rule-fit models that begin with rules extracted from a tree ensemble which are then added to a regularized linear or logistic regression.

Installation

You can install the released version of rules from CRAN with:

install.packages("rules")

Install the development version from GitHub with:

# install.packages("pak")
pak::pak("tidymodels/rules")

Available Engines

The rules package provides engines for the models in the following table.

model engine mode
C5_rules C5.0 classification
cubist_rules Cubist regression
rule_fit xrf classification
rule_fit xrf regression

Contributing

This project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

rules's People

Contributors

emilhvitfeldt avatar gaborcsardi avatar hfrick avatar jaredlander avatar juliasilge avatar simonpcouch avatar topepo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rules's Issues

Release rules 1.0.0

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Check if any deprecation processes should be advanced, as described in Gradual deprecation
  • Polish NEWS
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::cloud_check()
  • Update cran-comments.md
  • git push
  • Draft blog post
  • Slack link to draft blog in #open-source-comms

Submit to CRAN:

  • usethis::use_version('major')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

Parallel computation on Windows

I'm trying to parallelize my computation (on Windows 10 machine) but without success. I always get the same error.

library(tidymodels)
library(rules)
library(tidymodels)
library(future)
library(doFuture)

mt_train <- mtcars[1:25,]
mt_test  <- mtcars[26:32,]

recipe_mt <- recipe(mpg ~ ., data = mt_train)

# Model spec
model_spec_cubist <- cubist_rules(
    committees = 100,
    neighbors = 3, 
    max_rules = 100
) %>%
    set_engine("Cubist")

# Workflow
wflw <- workflow() %>% 
    add_model(model_spec_cubist) %>% 
    add_recipe(recipe_mt) %>% 
    fit(mt_train)

# Tune
model_spec <- cubist_rules(
    mode = "regression",
    committees = tune(),
    neighbors = tune(),
    max_rules = tune()
) %>%
    set_engine("Cubist")

grid_spec <- grid_latin_hypercube(
    parameters(model_spec),
    size = 10
)

# Update workflow
wflw <- wflw %>%
    update_model(model_spec)

resamples <- vfold_cv(
    data = mtcars,
    v = 5,
    repeats = 5
    
)

registerDoFuture()
n_cores <- detectCores()
plan(
    strategy = cluster,
    workers  = parallel::makeCluster(n_cores)
)

set.seed(123)
tune_results <- wflw %>%
    tune_grid(
        resamples = resamples,
        grid      = grid_spec,
        # metrics   = default_forecast_accuracy_metric_set(),
        metrics   = metric_set(rmse, rsq),
        control   = control_grid(verbose = FALSE, save_pred = TRUE)
    )

plan(strategy = sequential)

Results in:

x Fold1, Repeat1: internal: Error in rlang::env_get(mod_env, items): argument "default" is missing, with no default
Warning message:
All models failed in tune_grid(). See the `.notes` column. 

for all the folds.

Release rules 0.1.1

Prepare for release:

  • devtools::build_readme()
  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Polish NEWS

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()

Release rules 0.1.0

Prepare for release:

  • devtools::build_readme()
  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Polish NEWS
  • Review pkgdown reference index for, e.g., missing topics
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

tidy methods for C5 rules

Hi, there appears to be tidy methods for Cubist and RuleFit, but not for C5.0. Is an implementation available elsewhere? If not, can this be added to the rules packages?

Different trained models with the same configuration (rules and xrf package)

Hello, I have used rules package to create a rulefit model. But I do not manage to replicate it with the xrf package. I'm not specifying any hyperparameter neither rules nor xrf model.

In fact, these two models are quite different from each other. For instance, the rules package has 138 rules and the xrf package has 340. Besides, the output retrieved of two made-up observations is completely different as well.

Thank you for your work!

library(parsnip)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(rules)
library(mlbench)
library(xrf)

data(Ionosphere)

Ionosphere <- Ionosphere %>% select(V3, V4, V5, Class)

model_parsnip <- rule_fit() %>%
    set_mode('classification') %>%
    set_engine('xrf') %>%
    fit(Class ~ ., data = Ionosphere)


model_no_parsnip <- xrf(Class ~ .,
                     data = Ionosphere,
                     family = "binomial")

test_df <- tibble('V3' = c(1, 0), 'V4' = c(1,-0.5), 'V5' = c(0.3, 0.9))

model_parsnip
#> parsnip model object
#> 
#> Fit time:  3.2s 
#> An eXtreme RuleFit model of 138 rules.
#> 
#> Original Formula:
#> 
#> Class ~ V3 + V4 + V5
model_no_parsnip
#> An eXtreme RuleFit model of 340 rules.
#> 
#> Original Formula:
#> 
#> Class ~ V3 + V4 + V5

predict(model_parsnip, test_df, type = 'prob')
#> # A tibble: 2 x 2
#>   .pred_bad .pred_good
#>       <dbl>      <dbl>
#> 1     0.618      0.382
#> 2     0.696      0.304
predict(model_no_parsnip, test_df, type = 'response')
#>            1
#> 1 0.81670540
#> 2 0.01647708

Created on 2020-06-24 by the reprex package (v0.3.0)

Error: package or namespace load failed for ‘rules’:

I've been successfully loading the rules library and running Cubist models until recently I keep getting this error message after library(rules).

Error: package or namespace load failed for ‘rules’:
.onLoad failed in loadNamespace() for 'rules', details:
call: check_model_doesnt_exist(model)
error: Model cubist_rules already exists

I've tried uninstalling and reinstalling the package without succes. What am I missing here?

I'm running R version 4.1.2 (2021-11-01) -- "Bird Hippie" on platform: aarch64-apple-darwin20 (64-bit)

Tuning trees for C5_rules doesn't change performance

The problem

Tuning trees() when using parsnip::C5_rules() doesn't change performance (please refer to ggplot below).
I'm not sure if this is a bug or intended? And if it's indeed the latter, should trees() be removed as a hyperparameter to avoid confusion?

Reproducible example

library(tidyverse)
library(tidymodels)
#> Registered S3 method overwritten by 'tune':
#>   method                   from   
#>   required_pkgs.model_spec parsnip
#> Warning: package 'parsnip' was built under R version 4.1.3
library(rules)
#> 
#> Attaching package: 'rules'
#> The following object is masked from 'package:dials':
#> 
#>     max_rules
library(palmerpenguins)
#> Warning: package 'palmerpenguins' was built under R version 4.1.3

set.seed(2022)
penguins_split <- initial_split(penguins)
penguins_training <- training(penguins_split)
penguins_testing <- testing(penguins_split)

folds <- vfold_cv(penguins_training, v = 5)

simple_rec <- penguins_training %>% 
  recipe(species ~ .)

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

penguins_wf <- workflow() %>% 
  add_recipe(simple_rec) %>% 
  add_model(C5_model)

penguins_tuning <- tune_grid(
  object = penguins_wf,
  resamples = folds,
  grid = 30,
  control = control_grid(save_pred = TRUE, verbose = TRUE),
  metrics = metric_set(accuracy, roc_auc, f_meas)
)
#> Warning: package 'C50' was built under R version 4.1.3
#> i Fold1: preprocessor 1/1
#> v Fold1: preprocessor 1/1
#> i Fold1: preprocessor 1/1, model 1/1
#> v Fold1: preprocessor 1/1, model 1/1
#> i Fold1: preprocessor 1/1, model 1/1 (predictions)
#> i Fold2: preprocessor 1/1
#> v Fold2: preprocessor 1/1
#> i Fold2: preprocessor 1/1, model 1/1
#> v Fold2: preprocessor 1/1, model 1/1
#> i Fold2: preprocessor 1/1, model 1/1 (predictions)
#> i Fold3: preprocessor 1/1
#> v Fold3: preprocessor 1/1
#> i Fold3: preprocessor 1/1, model 1/1
#> v Fold3: preprocessor 1/1, model 1/1
#> i Fold3: preprocessor 1/1, model 1/1 (predictions)
#> i Fold4: preprocessor 1/1
#> v Fold4: preprocessor 1/1
#> i Fold4: preprocessor 1/1, model 1/1
#> v Fold4: preprocessor 1/1, model 1/1
#> i Fold4: preprocessor 1/1, model 1/1 (predictions)
#> i Fold5: preprocessor 1/1
#> v Fold5: preprocessor 1/1
#> i Fold5: preprocessor 1/1, model 1/1
#> v Fold5: preprocessor 1/1, model 1/1
#> i Fold5: preprocessor 1/1, model 1/1 (predictions)

collect_metrics(penguins_tuning) %>% 
  ggplot(aes(mean, trees, color = .metric)) +
  geom_point(show.legend = FALSE) +
  facet_wrap(~ .metric, scales = "free")

Created on 2022-03-25 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value
#>  version  R version 4.1.2 (2021-11-01)
#>  os       Windows 10 x64 (build 19042)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_Singapore.1252
#>  ctype    English_Singapore.1252
#>  tz       Asia/Kuala_Lumpur
#>  date     2022-03-25
#>  pandoc   2.14.0.3 @ C:/Program Files/RStudio/bin/pandoc/ (via rmarkdown)
#> 
#> - Packages -------------------------------------------------------------------
#>  package        * version    date (UTC) lib source
#>  assertthat       0.2.1      2019-03-21 [1] CRAN (R 4.1.2)
#>  backports        1.4.1      2021-12-13 [1] CRAN (R 4.1.2)
#>  broom          * 0.7.12     2022-01-28 [1] CRAN (R 4.1.2)
#>  C50            * 0.1.6      2022-02-05 [1] CRAN (R 4.1.3)
#>  cellranger       1.1.0      2016-07-27 [1] CRAN (R 4.1.2)
#>  class            7.3-19     2021-05-03 [2] CRAN (R 4.1.2)
#>  cli              3.1.0      2021-10-27 [1] CRAN (R 4.1.2)
#>  codetools        0.2-18     2020-11-04 [2] CRAN (R 4.1.2)
#>  colorspace       2.0-2      2021-06-24 [1] CRAN (R 4.1.2)
#>  crayon           1.4.2      2021-10-29 [1] CRAN (R 4.1.2)
#>  Cubist           0.4.0      2022-02-05 [1] CRAN (R 4.1.3)
#>  curl             4.3.2      2021-06-23 [1] CRAN (R 4.1.2)
#>  DBI              1.1.2      2021-12-20 [1] CRAN (R 4.1.2)
#>  dbplyr           2.1.1      2021-04-06 [1] CRAN (R 4.1.2)
#>  dials          * 0.1.0      2022-01-31 [1] CRAN (R 4.1.2)
#>  DiceDesign       1.9        2021-02-13 [1] CRAN (R 4.1.2)
#>  digest           0.6.29     2021-12-01 [1] CRAN (R 4.1.2)
#>  dplyr          * 1.0.8      2022-02-08 [1] CRAN (R 4.1.2)
#>  ellipsis         0.3.2      2021-04-29 [1] CRAN (R 4.1.2)
#>  evaluate         0.14       2019-05-28 [1] CRAN (R 4.1.2)
#>  fansi            0.5.0      2021-05-25 [1] CRAN (R 4.1.2)
#>  farver           2.1.0      2021-02-28 [1] CRAN (R 4.1.2)
#>  fastmap          1.1.0      2021-01-25 [1] CRAN (R 4.1.2)
#>  forcats        * 0.5.1      2021-01-27 [1] CRAN (R 4.1.2)
#>  foreach          1.5.2      2022-02-02 [1] CRAN (R 4.1.2)
#>  Formula          1.2-4      2020-10-16 [1] CRAN (R 4.1.1)
#>  fs               1.5.2      2021-12-08 [1] CRAN (R 4.1.2)
#>  furrr            0.2.3      2021-06-25 [1] CRAN (R 4.1.2)
#>  future           1.24.0     2022-02-19 [1] CRAN (R 4.1.2)
#>  future.apply     1.8.1      2021-08-10 [1] CRAN (R 4.1.2)
#>  generics         0.1.2      2022-01-31 [1] CRAN (R 4.1.2)
#>  ggplot2        * 3.3.5      2021-06-25 [1] CRAN (R 4.1.2)
#>  globals          0.14.0     2020-11-22 [1] CRAN (R 4.1.1)
#>  glue             1.6.2      2022-02-24 [1] CRAN (R 4.1.2)
#>  gower            0.2.2      2020-06-23 [1] CRAN (R 4.1.1)
#>  GPfit            1.0-8      2019-02-08 [1] CRAN (R 4.1.2)
#>  gtable           0.3.0      2019-03-25 [1] CRAN (R 4.1.2)
#>  hardhat          0.2.0      2022-01-24 [1] CRAN (R 4.1.2)
#>  haven            2.4.3      2021-08-04 [1] CRAN (R 4.1.2)
#>  highr            0.9        2021-04-16 [1] CRAN (R 4.1.2)
#>  hms              1.1.1      2021-09-26 [1] CRAN (R 4.1.2)
#>  htmltools        0.5.2      2021-08-25 [1] CRAN (R 4.1.2)
#>  httr             1.4.2      2020-07-20 [1] CRAN (R 4.1.2)
#>  infer          * 1.0.0      2021-08-13 [1] CRAN (R 4.1.2)
#>  inum             1.0-4      2021-04-12 [1] CRAN (R 4.1.2)
#>  ipred            0.9-12     2021-09-15 [1] CRAN (R 4.1.2)
#>  iterators        1.0.13     2020-10-15 [1] CRAN (R 4.1.2)
#>  jsonlite         1.7.2      2020-12-09 [1] CRAN (R 4.1.2)
#>  knitr            1.37       2021-12-16 [1] CRAN (R 4.1.2)
#>  labeling         0.4.2      2020-10-20 [1] CRAN (R 4.1.1)
#>  lattice          0.20-45    2021-09-22 [2] CRAN (R 4.1.2)
#>  lava             1.6.10     2021-09-02 [1] CRAN (R 4.1.2)
#>  lhs              1.1.3      2021-09-08 [1] CRAN (R 4.1.2)
#>  libcoin          1.0-9      2021-09-27 [1] CRAN (R 4.1.2)
#>  lifecycle        1.0.1      2021-09-24 [1] CRAN (R 4.1.2)
#>  listenv          0.8.0      2019-12-05 [1] CRAN (R 4.1.2)
#>  lubridate        1.8.0      2021-10-07 [1] CRAN (R 4.1.2)
#>  magrittr         2.0.2      2022-01-26 [1] CRAN (R 4.1.2)
#>  MASS             7.3-54     2021-05-03 [2] CRAN (R 4.1.2)
#>  Matrix           1.3-4      2021-06-01 [2] CRAN (R 4.1.2)
#>  mime             0.12       2021-09-28 [1] CRAN (R 4.1.1)
#>  modeldata      * 0.1.1      2021-07-14 [1] CRAN (R 4.1.2)
#>  modelr           0.1.8      2020-05-19 [1] CRAN (R 4.1.2)
#>  munsell          0.5.0      2018-06-12 [1] CRAN (R 4.1.2)
#>  mvtnorm          1.1-3      2021-10-08 [1] CRAN (R 4.1.1)
#>  nnet             7.3-16     2021-05-03 [2] CRAN (R 4.1.2)
#>  palmerpenguins * 0.1.0      2020-07-23 [1] CRAN (R 4.1.3)
#>  parallelly       1.30.0     2021-12-17 [1] CRAN (R 4.1.2)
#>  parsnip        * 0.2.0      2022-03-09 [1] CRAN (R 4.1.3)
#>  partykit         1.2-15     2021-08-23 [1] CRAN (R 4.1.2)
#>  pillar           1.7.0      2022-02-01 [1] CRAN (R 4.1.2)
#>  pkgconfig        2.0.3      2019-09-22 [1] CRAN (R 4.1.2)
#>  plyr             1.8.6      2020-03-03 [1] CRAN (R 4.1.2)
#>  pROC             1.18.0     2021-09-03 [1] CRAN (R 4.1.2)
#>  prodlim          2019.11.13 2019-11-17 [1] CRAN (R 4.1.2)
#>  purrr          * 0.3.4      2020-04-17 [1] CRAN (R 4.1.2)
#>  R6               2.5.1      2021-08-19 [1] CRAN (R 4.1.2)
#>  Rcpp             1.0.7      2021-07-07 [1] CRAN (R 4.1.2)
#>  readr          * 2.1.2      2022-01-30 [1] CRAN (R 4.1.2)
#>  readxl           1.3.1      2019-03-13 [1] CRAN (R 4.1.2)
#>  recipes        * 0.2.0      2022-02-18 [1] CRAN (R 4.1.2)
#>  reprex           2.0.1      2021-08-05 [1] CRAN (R 4.1.2)
#>  reshape2         1.4.4      2020-04-09 [1] CRAN (R 4.1.2)
#>  rlang          * 1.0.2      2022-03-04 [1] CRAN (R 4.1.2)
#>  rmarkdown        2.12       2022-03-02 [1] CRAN (R 4.1.2)
#>  rpart            4.1-15     2019-04-12 [2] CRAN (R 4.1.2)
#>  rsample        * 0.1.1      2021-11-08 [1] CRAN (R 4.1.2)
#>  rstudioapi       0.13       2020-11-12 [1] CRAN (R 4.1.2)
#>  rules          * 0.2.0      2022-03-14 [1] CRAN (R 4.1.2)
#>  rvest            1.0.2      2021-10-16 [1] CRAN (R 4.1.2)
#>  scales         * 1.1.1      2020-05-11 [1] CRAN (R 4.1.2)
#>  sessioninfo      1.2.2      2021-12-06 [1] CRAN (R 4.1.2)
#>  stringi          1.7.6      2021-11-29 [1] CRAN (R 4.1.2)
#>  stringr        * 1.4.0      2019-02-10 [1] CRAN (R 4.1.2)
#>  survival         3.2-13     2021-08-24 [2] CRAN (R 4.1.2)
#>  tibble         * 3.1.6      2021-11-07 [1] CRAN (R 4.1.2)
#>  tidymodels     * 0.1.4      2021-10-01 [1] CRAN (R 4.1.2)
#>  tidyr          * 1.2.0      2022-02-01 [1] CRAN (R 4.1.2)
#>  tidyselect       1.1.2      2022-02-21 [1] CRAN (R 4.1.2)
#>  tidyverse      * 1.3.1      2021-04-15 [1] CRAN (R 4.1.2)
#>  timeDate         3043.102   2018-02-21 [1] CRAN (R 4.1.1)
#>  tune           * 0.1.6      2021-07-21 [1] CRAN (R 4.1.2)
#>  tzdb             0.2.0      2021-10-27 [1] CRAN (R 4.1.2)
#>  utf8             1.2.2      2021-07-24 [1] CRAN (R 4.1.2)
#>  vctrs          * 0.3.8      2021-04-29 [1] CRAN (R 4.1.2)
#>  withr            2.4.3      2021-11-30 [1] CRAN (R 4.1.2)
#>  workflows      * 0.2.4      2021-10-12 [1] CRAN (R 4.1.2)
#>  workflowsets   * 0.1.0      2021-07-22 [1] CRAN (R 4.1.2)
#>  xfun             0.29       2021-12-14 [1] CRAN (R 4.1.2)
#>  xml2             1.3.3      2021-11-30 [1] CRAN (R 4.1.2)
#>  yaml             2.3.5      2022-02-21 [1] CRAN (R 4.1.2)
#>  yardstick      * 0.0.9      2021-11-22 [1] CRAN (R 4.1.2)
#> 
#>  [1] C:/Users/dchoy/Documents/R/win-library/4.1
#>  [2] C:/Program Files/R/R-4.1.2/library
#> 
#> ------------------------------------------------------------------------------

Move `master` branch to `main`

The master branch of this repository will soon be renamed to main, as part of a coordinated change across several GitHub organizations (including, but not limited to: tidyverse, r-lib, tidymodels, and sol-eng). We anticipate this will happen by the end of September 2021.

That will be preceded by a release of the usethis package, which will gain some functionality around detecting and adapting to a renamed default branch. There will also be a blog post at the time of this master --> main change.

The purpose of this issue is to:

  • Help us firm up the list of targetted repositories
  • Make sure all maintainers are aware of what's coming
  • Give us an issue to close when the job is done
  • Give us a place to put advice for collaborators re: how to adapt

message id: euphoric_snowdog

Predictions between cubist_rules and rule_fit are different when a formula includes log10

I am trying to apply rule_fit to example of Rules package 0.0.1.
Today, I found that the prediction results are different between cubist_rules and rule_fit when log10 function is included in the model formula.
Please check these results.

data(car_prices, package = "modeldata")
set.seed(9932)
car_split <- initial_split(car_prices)
car_train <- training(car_split)
car_test <- testing(car_split)

cubist_fit <-
  cubist_rules(neighbors = 9, committees = 9) %>% 
  set_engine("Cubist") %>% 
  fit(log10(Price) ~ ., data = car_train)

rulefit_fit <-
  rule_fit() %>% 
  set_mode("regression") %>%
  fit(log10(Price) ~ ., data = car_train)

res <- 
  bind_cols(
    predict(cubist_fit, new_data = car_train),
    predict(rulefit_fit, new_data = car_train)
  ) %>% 
  rename(cubist = .pred, rulefit = .pred1)
res

###   cubist rulefit
### 1   4.32  20214.
### 2   4.50  33250.
### 3   4.50  32423.
### 4   4.51  33244.
### 5   4.49  33563.

ps1: I hope that rule_fit tunning tutorial is attached in the documents.

Upkeep for rules

Pre-history

  • usethis::use_readme_rmd()
  • usethis::use_roxygen_md()
  • usethis::use_github_links()
  • usethis::use_pkgdown_github_pages()
  • usethis::use_tidy_github_labels()
  • usethis::use_tidy_style()
  • usethis::use_tidy_description()
  • urlchecker::url_check()

2020

  • usethis::use_package_doc()
    Consider letting usethis manage your @importFrom directives here.
    usethis::use_import_from() is handy for this.
  • usethis::use_testthat(3) and upgrade to 3e, testthat 3e vignette
  • Align the names of R/ files and test/ files for workflow happiness.
    usethis::rename_files() can be helpful.

2021

  • usethis::use_tidy_dependencies()
  • usethis::use_tidy_github_actions() and update artisanal actions to use setup-r-dependencies
  • Remove check environments section from cran-comments.md
  • Bump required R version in DESCRIPTION to 3.4
  • Use lifecycle instead of artisanal deprecation messages, as described in Communicate lifecycle changes in your functions
  • Make sure RStudio appears in Authors@R of DESCRIPTION like so, if appropriate:
    person("RStudio", role = c("cph", "fnd"))

2022

Error: undefined columns selected

The problem

I'm running many different ML algorithms an Cubist is giving me an error I can't solve.
I do have the developement version of the rules package.

/cc @mdancho84

Reproducible example

``` r
library(tidymodels)
#> -- Attaching packages -------------------------------------- tidymodels 0.1.1 --
#> v broom     0.7.2          v recipes   0.1.15    
#> v dials     0.0.9.9000     v rsample   0.0.8.9000
#> v dplyr     1.0.2          v tibble    3.0.4     
#> v ggplot2   3.3.2          v tidyr     1.1.2     
#> v infer     0.5.3          v tune      0.1.1.9001
#> v modeldata 0.1.0          v workflows 0.2.1.9000
#> v parsnip   0.1.4          v yardstick 0.0.7     
#> v purrr     0.3.4
#> Warning: package 'broom' was built under R version 4.0.3
#> Warning: package 'modeldata' was built under R version 4.0.3
#> Warning: package 'recipes' was built under R version 4.0.3
#> -- Conflicts ----------------------------------------- tidymodels_conflicts() --
#> x purrr::discard() masks scales::discard()
#> x dplyr::filter()  masks stats::filter()
#> x dplyr::lag()     masks stats::lag()
#> x recipes::step()  masks stats::step()
library(modeltime)
library(rules)
#> 
#> Attaching package: 'rules'
#> The following object is masked from 'package:dials':
#> 
#>     max_rules
library(timetk)
library(tidyverse)

df <- read_csv("https://raw.githubusercontent.com/vidarsumo/reprex_data/main/reprex_data.csv")
#> 
#> -- Column specification --------------------------------------------------------
#> cols(
#>   date = col_date(format = ""),
#>   sala = col_double(),
#>   abc = col_character(),
#>   id = col_double()
#> )

df$id <- as.character(df$id)
df <- df %>%
    mutate(sala = ifelse(sala < 0, 0, sala))

horizon <- 8
number_of_groups <- n_distinct(df$id)


full_data_tbl <- df %>%

    mutate(sala = log1p(sala)) %>%

    group_by(id) %>%
    future_frame(date, .length_out = horizon, .bind_data = TRUE) %>%

    # Add lags and rolling features / Fouries
    mutate(id = as_factor(id)) %>%
    group_by(id) %>%
    arrange(date) %>%
    tk_augment_fourier(date, .periods = c(1:6, 8, 10, 12, 26, 52), .K = 5) %>%
    tk_augment_lags(sala, .lags = horizon) %>%
    tk_augment_slidify(
        paste0("sala_lag", horizon),
        # sala_lag12,
        .f = ~mean(.x, na.rm = TRUE),
        .period = c(4, 8, 26, 52),
        .partial = TRUE,
        .align = "center"
    ) %>%
    rowid_to_column(var = "rowid")
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4
#> New names:
#> * NA -> ...1
#> * NA -> ...2
#> * NA -> ...3
#> * NA -> ...4


data_prepared_tbl <- full_data_tbl %>%
    filter(!is.na(sala)) %>%
    drop_na()

splits <- data_prepared_tbl %>%
    time_series_split(date, assess = horizon, cumulative = TRUE)
#> Groups detected. Removing groups.
#> Data is not ordered by the 'date_var'. Resamples will be arranged by `date`.
#> Overlapping Timestamps Detected. Processing overlapping time series together using sliding windows.



recipe_spec <- recipe(sala ~ ., data = training(splits)) %>%
    update_role(rowid, new_role = "indicator") %>%
    step_timeseries_signature(date) %>%
    step_rm(matches("(.xts)|(.iso)|(hour)|(minute)|(second)|(am.pm)")) %>%
    step_rm(contains("day")) %>%
    step_ns(contains("index.num"), deg_free = 3) %>%
    step_normalize(contains("index.num"), date_year) %>%
    step_other(id, threshold = 1/(number_of_groups + 1)) %>%
    step_dummy(all_nominal(), one_hot = TRUE) %>%
    update_role(date, new_role = "indicator")


wlfw_fit_cubist <- workflow() %>%
    add_model(
        spec = cubist_rules(mode = "regression") %>% set_engine("Cubist")
    ) %>%
    add_recipe(recipe_spec) %>%
    fit(training(splits))
#> Error in `[.data.frame`(x, , as.character(splits$variable[i])): undefined columns selected
#> Timing stopped at: 2.85 0.02 2.86

Created on 2020-11-15 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  Icelandic_Iceland.1252      
#>  ctype    Icelandic_Iceland.1252      
#>  tz       Africa/Casablanca           
#>  date     2020-11-15                  
#> 
#> - Packages -------------------------------------------------------------------
#>  ! package      * version    date       lib
#>    assertthat     0.2.1      2019-03-21 [1]
#>    backports      1.2.0      2020-11-02 [1]
#>    broom        * 0.7.2      2020-10-20 [1]
#>    callr          3.5.1      2020-10-13 [1]
#>    cellranger     1.1.0      2016-07-27 [1]
#>    class          7.3-17     2020-04-26 [2]
#>    cli            2.1.0      2020-10-12 [1]
#>    codetools      0.2-16     2018-12-24 [2]
#>    colorspace     2.0-0      2020-11-11 [1]
#>    crayon         1.3.4      2017-09-16 [1]
#>    Cubist         0.2.3      2020-01-10 [1]
#>    curl           4.3        2019-12-02 [1]
#>    DBI            1.1.0      2019-12-15 [1]
#>    dbplyr         2.0.0      2020-11-03 [1]
#>    desc           1.2.0      2018-05-01 [1]
#>    devtools       2.3.2      2020-09-18 [1]
#>    dials        * 0.0.9.9000 2020-09-20 [1]
#>    DiceDesign     1.8-1      2019-07-31 [1]
#>    digest         0.6.27     2020-10-24 [1]
#>    dplyr        * 1.0.2      2020-08-18 [1]
#>    ellipsis       0.3.1      2020-05-15 [1]
#>    evaluate       0.14       2019-05-28 [1]
#>    fansi          0.4.1      2020-01-08 [1]
#>    forcats      * 0.5.0      2020-03-01 [1]
#>    foreach        1.5.1      2020-10-15 [1]
#>    fs             1.5.0      2020-07-31 [1]
#>    furrr          0.2.1      2020-10-21 [1]
#>    future         1.20.1     2020-11-03 [1]
#>    generics       0.1.0      2020-10-31 [1]
#>    ggplot2      * 3.3.2      2020-06-19 [1]
#>    globals        0.13.1     2020-10-11 [1]
#>    glue           1.4.2      2020-08-27 [1]
#>    gower          0.2.2      2020-06-23 [1]
#>    GPfit          1.0-8      2019-02-08 [1]
#>    gtable         0.3.0      2019-03-25 [1]
#>    hardhat        0.1.5      2020-11-09 [1]
#>    haven          2.3.1      2020-06-01 [1]
#>    highr          0.8        2019-03-20 [1]
#>    hms            0.5.3      2020-01-08 [1]
#>    htmltools      0.5.0      2020-06-16 [1]
#>    httr           1.4.2      2020-07-20 [1]
#>    infer        * 0.5.3      2020-07-14 [1]
#>    ipred          0.9-9      2019-04-28 [1]
#>    iterators      1.0.13     2020-10-15 [1]
#>    jsonlite       1.7.1      2020-09-07 [1]
#>    knitr          1.30       2020-09-22 [1]
#>    lattice        0.20-41    2020-04-02 [2]
#>    lava           1.6.8.1    2020-11-04 [1]
#>    lhs            1.1.1      2020-10-05 [1]
#>    lifecycle      0.2.0      2020-03-06 [1]
#>    listenv        0.8.0      2019-12-05 [1]
#>    lubridate      1.7.9.2    2020-11-13 [1]
#>    magrittr       1.5        2014-11-22 [1]
#>    MASS           7.3-51.6   2020-04-26 [2]
#>    Matrix         1.2-18     2019-11-27 [2]
#>    memoise        1.1.0      2017-04-21 [1]
#>    modeldata    * 0.1.0      2020-10-22 [1]
#>    modelr         0.1.8      2020-05-19 [1]
#>    modeltime    * 0.3.1.9000 2020-11-15 [1]
#>    munsell        0.5.0      2018-06-12 [1]
#>    nnet           7.3-14     2020-04-26 [2]
#>    parallelly     1.21.0     2020-10-27 [1]
#>    parsnip      * 0.1.4      2020-10-27 [1]
#>    pillar         1.4.6      2020-07-10 [1]
#>    pkgbuild       1.1.0      2020-07-13 [1]
#>    pkgconfig      2.0.3      2019-09-22 [1]
#>    pkgload        1.1.0      2020-05-29 [1]
#>    plyr           1.8.6      2020-03-03 [1]
#>    prettyunits    1.1.1      2020-01-24 [1]
#>    pROC           1.16.2     2020-03-19 [1]
#>    processx       3.4.4      2020-09-03 [1]
#>    prodlim        2019.11.13 2019-11-17 [1]
#>    ps             1.4.0      2020-10-07 [1]
#>    purrr        * 0.3.4      2020-04-17 [1]
#>    R6             2.5.0      2020-10-28 [1]
#>    Rcpp           1.0.5      2020-07-06 [1]
#>  D RcppParallel   5.0.2      2020-06-24 [1]
#>    readr        * 1.4.0      2020-10-05 [1]
#>    readxl         1.3.1      2019-03-13 [1]
#>    recipes      * 0.1.15     2020-11-11 [1]
#>    remotes        2.2.0      2020-07-21 [1]
#>    reprex         0.3.0      2019-05-16 [1]
#>    reshape2       1.4.4      2020-04-09 [1]
#>    rlang          0.4.8      2020-10-08 [1]
#>    rmarkdown      2.5        2020-10-21 [1]
#>    rpart          4.1-15     2019-04-12 [2]
#>    rprojroot      2.0.2      2020-11-15 [1]
#>    rsample      * 0.0.8.9000 2020-10-31 [1]
#>    rstudioapi     0.13       2020-11-12 [1]
#>    rules        * 0.1.0.9000 2020-11-15 [1]
#>    rvest          0.3.6      2020-07-25 [1]
#>    scales       * 1.1.1      2020-05-11 [1]
#>    sessioninfo    1.1.1      2018-11-05 [1]
#>    slider         0.1.5      2020-07-21 [1]
#>    StanHeaders    2.21.0-6   2020-08-16 [1]
#>    stringi        1.5.3      2020-09-09 [1]
#>    stringr      * 1.4.0      2019-02-10 [1]
#>    survival       3.1-12     2020-04-10 [2]
#>    testthat       3.0.0      2020-10-31 [1]
#>    tibble       * 3.0.4      2020-10-12 [1]
#>    tidymodels   * 0.1.1      2020-07-14 [1]
#>    tidyr        * 1.1.2      2020-08-27 [1]
#>    tidyselect     1.1.0      2020-05-11 [1]
#>    tidyverse    * 1.3.0      2019-11-21 [1]
#>    timeDate       3043.102   2018-02-21 [1]
#>    timetk       * 2.5.0.9000 2020-11-15 [1]
#>    tune         * 0.1.1.9001 2020-10-31 [1]
#>    usethis        1.6.3      2020-09-17 [1]
#>    vctrs          0.3.4      2020-08-29 [1]
#>    warp           0.2.0      2020-10-21 [1]
#>    withr          2.3.0      2020-09-22 [1]
#>    workflows    * 0.2.1.9000 2020-10-10 [1]
#>    xfun           0.19       2020-10-30 [1]
#>    xml2           1.3.2      2020-04-23 [1]
#>    xts            0.12.1     2020-09-09 [1]
#>    yaml           2.2.1      2020-02-01 [1]
#>    yardstick    * 0.0.7      2020-07-13 [1]
#>    zoo            1.8-8      2020-05-02 [1]
#>  source                                     
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.3)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  Github (tidymodels/dials@2b79300)          
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.3)                             
#>  CRAN (R 4.0.1)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.1)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.1)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.1)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.3)                             
#>  CRAN (R 4.0.0)                             
#>  Github (business-science/modeltime@69329e5)
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.3)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.3)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#>  Github (tidymodels/rsample@13f990b)        
#>  CRAN (R 4.0.3)                             
#>  Github (tidymodels/rules@ecbbc5d)          
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.1)                             
#>  CRAN (R 4.0.1)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.3)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.1)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.0)                             
#>  Github (business-science/timetk@4f6882d)   
#>  Github (tidymodels/tune@a8ef10e)           
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.1)                             
#>  CRAN (R 4.0.3)                             
#>  CRAN (R 4.0.2)                             
#>  Github (tidymodels/workflows@8f5d914)      
#>  CRAN (R 4.0.3)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.0)                             
#>  CRAN (R 4.0.2)                             
#>  CRAN (R 4.0.2)                             
#> 
#> [1] C:/Users/vidar/Documents/R/win-library/4.0
#> [2] C:/Program Files/R/R-4.0.2/library
#> 
#>  D -- DLL MD5 mismatch, broken installation.

Coefficients reported by the tidy and coef method in a rule_fit model are not equal

Hello! I am not sure whether this is the expected behavior, but when I use the function tidy() in a rules::rule_fit model, the list of features (and their coefficients) reported do not coincide with the coef() output.

If this is the correct behavior, which coefficients are being reported?

You can find an example below:

library(rules)
#> Le chargement a nécessité le package : parsnip
library(yardstick)
#> For binary classification, the first factor level is assumed to be the event.
#> Use the argument `event_level = "second"` to alter this as needed.
library(parsnip)
library(broom)
library(dplyr)
#> 
#> Attachement du package : 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
test_rulefit <- rules::rule_fit() %>%
  set_mode('classification') %>%
  set_engine('xrf') %>%
  fit(am ~ ., mtcars %>% mutate(am = as.factor(am)))
#> New names:
#> * . -> ....1
#> * . -> ....2
#> * . -> ....3
#> * . -> ....4
#> * . -> ....5
#> * ...

test_rulefit %>% tidy()
#> # A tibble: 5 x 3
#>   rule_id     rule                                          estimate
#>   <chr>       <chr>                                            <dbl>
#> 1 (Intercept) ( TRUE )                                        -5.01 
#> 2 gear        ( gear )                                         1.11 
#> 3 r0_3        ( qsec <  19.1849995 ) & ( wt <  3.18000007 )    0.162
#> 4 r1_3        ( hp <  222.5 ) & ( wt >= 3.01250005 )          -0.841
#> 5 r2_3        ( gear >= 3.5 ) & ( wt <  3.01250005 )           2.06

test_rulefit$fit %>% coef() %>% filter(coefficient_lambda.min != 0)
#>   coefficient_lambda.min        term                      rule
#> 1           -15.48490246 (Intercept)                      <NA>
#> 2            -2.30560971        r1_3  hp<222.500 & wt>=  3.013
#> 3            -1.31716484        r8_4 qsec>=17.410 & wt>= 3.013
#> 4             0.08077928        r7_3  gear>= 3.50 & qsec<18.76
#> 5             0.24635541        r0_3     qsec<19.18 & wt< 3.18
#> 6             0.50798063        r5_3  gear>= 3.50 & qsec<17.66
#> 7             3.71180516        gear                      <NA>
#> 8             5.16985334        r2_3    gear>=3.500 & wt<3.013

Created on 2021-03-19 by the reprex package (v0.3.0)

Release rules 0.0.3

Prepare for release:

  • devtools::build_readme()
  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Polish NEWS

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()

move model definitions to parsnip

We are standardizing to have our parsnip-adjacent package keep their model definitions in parsnip so that other packages can add engines.

This package should take a version dependency of parsnip >= 0.1.7.9000.

Release rules 1.0.1

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Polish NEWS
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::cloud_check()
  • Update cran-comments.md
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push

new warning coming from xrf::xrf()

Happens in test-rule-fit-binomial.R, test-rule-fit-multinomial.R, and test-rule-fit-regression.R.

library(rules)
#> Loading required package: parsnip

data("ad_data", package = "modeldata")

ad_mod  <- ad_data %>% 
  dplyr::slice(-(1:10)) %>% 
  dplyr::select(Class, Genotype, p_tau, MMP10)

set.seed(4526)
rf_fit_exp <-
  xrf::xrf(
    Class ~ .,
    data = ad_mod,
    family = "binomial",
    xgb_control = list(nrounds = 3, min_child_weight = 3, penalty = 1),
    verbose = 0
  )
#> [16:33:02] WARNING: src/learner.cc:767: 
#> Parameters: { "penalty" } are not used.

Created on 2024-04-09 with reprex v2.1.0

Lots of "New name:"

Having looked everywhere, but in test-rule-fit-regression.R at least, I see a lot of this, which properly isn't too hard to remove

New names:

  • . -> ....1
  • . -> ....2
  • . -> ....3
  • . -> ....4
  • . -> ....5
  • . -> ....6
  • . -> ....7
  • . -> ....8
  • . -> ....9
  • . -> ....10
  • . -> ....11
  • . -> ....12
  • . -> ....13
  • . -> ....14
  • . -> ....15
  • . -> ....16
  • . -> ....17
  • . -> ....18
  • . -> ....19

Release rules 1.0.2

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Polish NEWS
  • urlchecker::url_check()
  • devtools::build_readme()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • revdepcheck::cloud_check()
  • Update cran-comments.md
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)

Release rules 0.2.0

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Polish NEWS
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::cloud_check()
  • Update cran-comments.md
  • Review pkgdown reference index for, e.g., missing topics
  • git push
  • Draft blog post
  • Slack link to draft blog in #open-source-comms

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

min_n can't be tuned

> C5_rules() %>% set_engine("C5.0") %>% tunable()
# A tibble: 1 x 5
  name  call_info        source     component component_id
  <chr> <list>           <chr>      <chr>     <chr>       
1 trees <named list [3]> model_spec C5_rules  main    

Release rules 0.0.2

Prepare for release:

  • devtools::build_readme()
  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Polish NEWS

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()

Caculation is slow in tidymodels-rules compared with caret-cubist

I am a beginner in both caret and tidymodels and trying to adapt tidymodels-rules to my analysis.

When using doParallel pkg, I realized that the caret-cubist calculates much faster than the tidymodels-cubist. Is there a special reason of speed difference between them?
I guest the basic engine in two frameworks are similar.

The link is a basic tutorial and I attached doParallel chunk and adapted to make the same training condition:
caret vs tidymodels example

Upkeep for rules

2023

Necessary:

  • Update copyright holder in DESCRIPTION: person(given = "Posit Software, PBC", role = c("cph", "fnd"))
  • Double check license file uses '[package] authors' as copyright holder. Run use_mit_license()
  • Update logo (https://github.com/rstudio/hex-stickers); run use_tidy_logo()
  • usethis::use_tidy_coc()
  • usethis::use_tidy_github_actions()

Optional:

  • Review 2022 checklist to see if you completed the pkgdown updates
  • Prefer pak::pak("org/pkg") over devtools::install_github("org/pkg") in README
  • Consider running use_tidy_dependencies() and/or replace compat files with use_standalone()
  • use_standalone("r-lib/rlang", "types-check") instead of home grown argument checkers
  • Add alt-text to pictures, plots, etc; see https://posit.co/blog/knitr-fig-alt/ for examples

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.