Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intercepts in cubist formula #58

Open
topepo opened this issue Jul 17, 2019 · 0 comments
Open

intercepts in cubist formula #58

topepo opened this issue Jul 17, 2019 · 0 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@topepo
Copy link
Member

topepo commented Jul 17, 2019

The intercept object is being added to the parsed model formula (I think instead of its value).

In the example below should list(list(col = "(Intercept)", val = 15.173, op = "none", is_intercept = 1)) be 15.173?

``` r
library(Cubist)
#> Loading required package: lattice
library(tidymodels)
#> Registered S3 method overwritten by 'xts':
#>   method     from
#>   as.zoo.xts zoo
#> ── Attaching packages ────────────────────────────────────────────────────────── tidymodels 0.0.2 ──
#> ✔ broom     0.5.1          ✔ purrr     0.3.2     
#> ✔ dials     0.0.2.9000     ✔ recipes   0.1.6     
#> ✔ dplyr     0.8.3          ✔ rsample   0.0.5.9000
#> ✔ ggplot2   3.2.0          ✔ tibble    2.1.3     
#> ✔ infer     0.4.0          ✔ yardstick 0.0.2     
#> ✔ parsnip   0.0.2.9000
#> ── Conflicts ───────────────────────────────────────────────────────────── tidymodels_conflicts() ──
#> ✖ purrr::discard()  masks scales::discard()
#> ✖ dplyr::filter()   masks stats::filter()
#> ✖ dplyr::lag()      masks stats::lag()
#> ✖ ggplot2::margin() masks dials::margin()
#> ✖ recipes::step()   masks stats::step()
library(tidypredict)
library(sessioninfo)
options(width = 100)

data(biomass)

biomass_tr <-
  biomass %>%
  dplyr::filter(dataset == "Training") %>%
  dplyr::select(-dataset, -sample)

biomass_te <-
  biomass %>%
  dplyr::filter(dataset == "Testing") %>%
  dplyr::select(-dataset, -sample)

set.seed(1)
mod <- cubist(x = biomass_tr %>% dplyr::select(-HHV), y = biomass_tr$HHV)
tidypredict_fit(mod)
#> (ifelse(oxygen >= 51.59, list(list(col = "(Intercept)", val = 15.173, 
#>     op = "none", is_intercept = 1)), 0) + ifelse(oxygen < 42.49 & 
#>     carbon < 60.97 & hydrogen < 6.85, 0.12089 + carbon * 0.362 + 
#>     hydrogen * 0.31 + oxygen * -0.009 + sulfur * 0.3, 0) + ifelse(oxygen >= 
#>     42.49 & oxygen < 51.59, 10.20375 + carbon * 0.299 + oxygen * 
#>     -0.123, 0) + ifelse(hydrogen >= 6.85 & carbon < 60.97, -13.1916 + 
#>     carbon * 0.693, 0) + ifelse(carbon >= 60.97 & nitrogen >= 
#>     1.36, 64.2476 + carbon * 0.028 + hydrogen * 0.09 + nitrogen * 
#>     -24.5, 0) + ifelse(carbon >= 60.97 & nitrogen < 1.36, -2.69375 + 
#>     carbon * 0.363 + hydrogen * 1.38 + nitrogen * 0.38, 0))/1

session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.0 (2019-04-26)
#>  os       macOS High Sierra 10.13.6   
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       America/New_York            
#>  date     2019-07-16                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────────────────────────
#>  package       * version    date       lib source                            
#>  assertthat      0.2.1      2019-03-21 [1] CRAN (R 3.6.0)                    
#>  backports       1.1.4      2019-04-10 [1] CRAN (R 3.6.0)                    
#>  base64enc       0.1-3      2015-07-28 [1] CRAN (R 3.6.0)                    
#>  bayesplot       1.6.0      2018-08-02 [1] CRAN (R 3.6.0)                    
#>  broom         * 0.5.1      2018-12-05 [1] CRAN (R 3.6.0)                    
#>  callr           3.2.0      2019-03-15 [1] CRAN (R 3.6.0)                    
#>  class           7.3-15     2019-01-01 [1] CRAN (R 3.6.0)                    
#>  cli             1.1.0      2019-03-19 [1] CRAN (R 3.6.0)                    
#>  codetools       0.2-16     2018-12-24 [1] CRAN (R 3.6.0)                    
#>  colorspace      1.4-1      2019-03-18 [1] CRAN (R 3.6.0)                    
#>  colourpicker    1.0        2017-09-27 [1] CRAN (R 3.6.0)                    
#>  crayon          1.3.4      2017-09-16 [1] CRAN (R 3.6.0)                    
#>  crosstalk       1.0.0      2016-12-21 [1] CRAN (R 3.6.0)                    
#>  Cubist        * 0.2.2      2018-05-21 [1] CRAN (R 3.6.0)                    
#>  dials         * 0.0.2.9000 2019-07-08 [1] local                             
#>  DiceDesign      1.8        2018-10-29 [1] CRAN (R 3.6.0)                    
#>  digest          0.6.20     2019-07-04 [1] CRAN (R 3.6.0)                    
#>  dplyr         * 0.8.3      2019-07-04 [1] CRAN (R 3.6.0)                    
#>  DT              0.5        2018-11-05 [1] CRAN (R 3.6.0)                    
#>  dygraphs        1.1.1.6    2018-07-11 [1] CRAN (R 3.6.0)                    
#>  evaluate        0.14       2019-05-28 [1] CRAN (R 3.6.0)                    
#>  furrr           0.1.0      2018-05-16 [1] CRAN (R 3.6.0)                    
#>  future          1.14.0     2019-07-02 [1] CRAN (R 3.6.0)                    
#>  generics        0.0.2      2018-11-29 [1] CRAN (R 3.6.0)                    
#>  ggplot2       * 3.2.0      2019-06-16 [1] CRAN (R 3.6.0)                    
#>  ggridges        0.5.1      2018-09-27 [1] CRAN (R 3.6.0)                    
#>  globals         0.12.4     2018-10-11 [1] CRAN (R 3.6.0)                    
#>  glue            1.3.1      2019-03-12 [1] CRAN (R 3.6.0)                    
#>  gower           0.2.0      2019-03-07 [1] CRAN (R 3.6.0)                    
#>  gridExtra       2.3        2017-09-09 [1] CRAN (R 3.6.0)                    
#>  gtable          0.3.0      2019-03-25 [1] CRAN (R 3.6.0)                    
#>  gtools          3.8.1      2018-06-26 [1] CRAN (R 3.6.0)                    
#>  highr           0.8        2019-03-20 [1] CRAN (R 3.6.0)                    
#>  htmltools       0.3.6      2017-04-28 [1] CRAN (R 3.6.0)                    
#>  htmlwidgets     1.3        2018-09-30 [1] CRAN (R 3.6.0)                    
#>  httpuv          1.5.1      2019-04-05 [1] CRAN (R 3.6.0)                    
#>  igraph          1.2.4      2019-02-13 [1] CRAN (R 3.6.0)                    
#>  infer         * 0.4.0      2018-11-15 [1] CRAN (R 3.6.0)                    
#>  inline          0.3.15     2018-05-18 [1] CRAN (R 3.6.0)                    
#>  ipred           0.9-8      2018-11-05 [1] CRAN (R 3.6.0)                    
#>  janeaustenr     0.1.5      2017-06-10 [1] CRAN (R 3.6.0)                    
#>  knitr           1.23       2019-05-18 [1] CRAN (R 3.6.0)                    
#>  later           0.8.0      2019-02-11 [1] CRAN (R 3.6.0)                    
#>  lattice       * 0.20-38    2018-11-04 [1] CRAN (R 3.6.0)                    
#>  lava            1.6.5      2019-02-12 [1] CRAN (R 3.6.0)                    
#>  lazyeval        0.2.2      2019-03-15 [1] CRAN (R 3.6.0)                    
#>  listenv         0.7.0      2018-01-21 [1] CRAN (R 3.6.0)                    
#>  lme4            1.1-20     2019-02-04 [1] CRAN (R 3.6.0)                    
#>  loo             2.0.0      2018-04-11 [1] CRAN (R 3.6.0)                    
#>  lubridate       1.7.4      2018-04-11 [1] CRAN (R 3.5.0)                    
#>  magrittr        1.5        2014-11-22 [1] CRAN (R 3.6.0)                    
#>  markdown        1.0        2019-06-07 [1] CRAN (R 3.6.0)                    
#>  MASS            7.3-51.4   2019-03-31 [1] CRAN (R 3.6.0)                    
#>  Matrix          1.2-17     2019-03-22 [1] CRAN (R 3.6.0)                    
#>  matrixStats     0.54.0     2018-07-23 [1] CRAN (R 3.6.0)                    
#>  mime            0.7        2019-06-11 [1] CRAN (R 3.6.0)                    
#>  miniUI          0.1.1.1    2018-05-18 [1] CRAN (R 3.6.0)                    
#>  minqa           1.2.4      2014-10-09 [1] CRAN (R 3.6.0)                    
#>  munsell         0.5.0      2018-06-12 [1] CRAN (R 3.6.0)                    
#>  nlme            3.1-139    2019-04-09 [1] CRAN (R 3.6.0)                    
#>  nloptr          1.2.1      2018-10-03 [1] CRAN (R 3.6.0)                    
#>  nnet            7.3-12     2016-02-02 [1] CRAN (R 3.6.0)                    
#>  parsnip       * 0.0.2.9000 2019-07-16 [1] local                             
#>  pillar          1.4.2      2019-06-29 [1] CRAN (R 3.6.0)                    
#>  pkgbuild        1.0.3      2019-03-20 [1] CRAN (R 3.6.0)                    
#>  pkgconfig       2.0.2      2018-08-16 [1] CRAN (R 3.6.0)                    
#>  plyr            1.8.4      2016-06-08 [1] CRAN (R 3.6.0)                    
#>  prettyunits     1.0.2      2015-07-13 [1] CRAN (R 3.6.0)                    
#>  pROC            1.14.0     2019-03-12 [1] CRAN (R 3.6.0)                    
#>  processx        3.4.0      2019-07-03 [1] CRAN (R 3.6.0)                    
#>  prodlim         2018.04.18 2018-04-18 [1] CRAN (R 3.6.0)                    
#>  promises        1.0.1      2018-04-13 [1] CRAN (R 3.6.0)                    
#>  ps              1.3.0      2018-12-21 [1] CRAN (R 3.6.0)                    
#>  purrr         * 0.3.2      2019-03-15 [1] CRAN (R 3.6.0)                    
#>  R6              2.4.0      2019-02-14 [1] CRAN (R 3.6.0)                    
#>  Rcpp            1.0.1      2019-03-17 [1] CRAN (R 3.6.0)                    
#>  recipes       * 0.1.6      2019-07-02 [1] CRAN (R 3.6.0)                    
#>  reshape2        1.4.3      2017-12-11 [1] CRAN (R 3.6.0)                    
#>  rlang           0.4.0.9000 2019-07-09 [1] Github (r-lib/rlang@a3d7e47)      
#>  rmarkdown       1.14       2019-07-12 [1] CRAN (R 3.6.0)                    
#>  rpart           4.1-15     2019-04-12 [1] CRAN (R 3.6.0)                    
#>  rsample       * 0.0.5.9000 2019-07-12 [1] local                             
#>  rsconnect       0.8.13     2019-01-10 [1] CRAN (R 3.6.0)                    
#>  rstan           2.18.2     2018-11-07 [1] CRAN (R 3.6.0)                    
#>  rstanarm        2.18.2     2018-11-10 [1] CRAN (R 3.6.0)                    
#>  rstantools      1.5.1      2018-08-22 [1] CRAN (R 3.6.0)                    
#>  rstudioapi      0.10       2019-03-19 [1] CRAN (R 3.6.0)                    
#>  scales        * 1.0.0      2018-08-09 [1] CRAN (R 3.6.0)                    
#>  sessioninfo   * 1.1.1.9000 2019-03-26 [1] Github (r-lib/sessioninfo@dfb3ea8)
#>  shiny           1.2.0      2018-11-02 [1] CRAN (R 3.6.0)                    
#>  shinyjs         1.0        2018-01-08 [1] CRAN (R 3.6.0)                    
#>  shinystan       2.5.0      2018-05-01 [1] CRAN (R 3.6.0)                    
#>  shinythemes     1.1.2      2018-11-06 [1] CRAN (R 3.6.0)                    
#>  SnowballC       0.6.0      2019-01-15 [1] CRAN (R 3.6.0)                    
#>  StanHeaders     2.18.1     2019-01-28 [1] CRAN (R 3.6.0)                    
#>  stringi         1.4.3      2019-03-12 [1] CRAN (R 3.6.0)                    
#>  stringr         1.4.0      2019-02-10 [1] CRAN (R 3.6.0)                    
#>  survival        2.44-1.1   2019-04-01 [1] CRAN (R 3.6.0)                    
#>  threejs         0.3.1      2017-08-13 [1] CRAN (R 3.6.0)                    
#>  tibble        * 2.1.3      2019-06-06 [1] CRAN (R 3.6.0)                    
#>  tidymodels    * 0.0.2      2019-07-03 [1] local                             
#>  tidyposterior   0.0.2      2018-11-15 [1] CRAN (R 3.6.0)                    
#>  tidypredict   * 0.4.2      2019-07-15 [1] local                             
#>  tidyr         * 0.8.3      2019-03-01 [1] CRAN (R 3.6.0)                    
#>  tidyselect      0.2.5      2018-10-11 [1] CRAN (R 3.6.0)                    
#>  tidytext        0.2.0      2018-10-17 [1] CRAN (R 3.6.0)                    
#>  timeDate        3043.102   2018-02-21 [1] CRAN (R 3.6.0)                    
#>  tokenizers      0.2.1      2018-03-29 [1] CRAN (R 3.6.0)                    
#>  vctrs           0.2.0.9000 2019-07-15 [1] Github (r-lib/vctrs@a8fb108)      
#>  withr           2.1.2      2018-03-15 [1] CRAN (R 3.6.0)                    
#>  xfun            0.8        2019-06-25 [1] CRAN (R 3.6.0)                    
#>  xtable          1.8-3      2018-08-29 [1] CRAN (R 3.6.0)                    
#>  xts             0.11-2     2018-11-05 [1] CRAN (R 3.6.0)                    
#>  yaml            2.2.0      2018-07-25 [1] CRAN (R 3.6.0)                    
#>  yardstick     * 0.0.2      2018-11-05 [1] CRAN (R 3.6.0)                    
#>  zeallot         0.1.0      2018-01-28 [1] CRAN (R 3.6.0)                    
#>  zoo             1.8-6      2019-05-28 [1] CRAN (R 3.6.0)                    
#> 
#> [1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

Created on 2019-07-16 by the reprex package (v0.2.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant