The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

tidyrules

Build Status CRAN_Status_Badge

tidyrules converts texual rules from models to dataframes with parseable rules. Supported models are: C5, cubist and rpart.

Example

library(tidyrules)
model_c5 = C50::C5.0(Species ~ ., data = iris, rules = TRUE)
summary(model_c5)
#> 
#> Call:
#> C5.0.formula(formula = Species ~ ., data = iris, rules = TRUE)
#> 
#> 
#> C5.0 [Release 2.07 GPL Edition]      Tue Dec 10 14:47:18 2019
#> -------------------------------
#> 
#> Class specified by attribute `outcome'
#> 
#> Read 150 cases (5 attributes) from undefined.data
#> 
#> Rules:
#> 
#> Rule 1: (50, lift 2.9)
#>  Petal.Length <= 1.9
#>  ->  class setosa  [0.981]
#> 
#> Rule 2: (48/1, lift 2.9)
#>  Petal.Length > 1.9
#>  Petal.Length <= 4.9
#>  Petal.Width <= 1.7
#>  ->  class versicolor  [0.960]
#> 
#> Rule 3: (46/1, lift 2.9)
#>  Petal.Width > 1.7
#>  ->  class virginica  [0.958]
#> 
#> Rule 4: (46/2, lift 2.8)
#>  Petal.Length > 4.9
#>  ->  class virginica  [0.938]
#> 
#> Default class: setosa
#> 
#> 
#> Evaluation on training data (150 cases):
#> 
#>          Rules     
#>    ----------------
#>      No      Errors
#> 
#>       4    4( 2.7%)   <<
#> 
#> 
#>     (a)   (b)   (c)    <-classified as
#>    ----  ----  ----
#>      50                (a): class setosa
#>            47     3    (b): class versicolor
#>             1    49    (c): class virginica
#> 
#> 
#>  Attribute usage:
#> 
#>   96.00% Petal.Length
#>   62.67% Petal.Width
#> 
#> 
#> Time: 0.0 secs

Tidy the rules:

pander::pandoc.table(tidyRules(model_c5), split.tables = 120)
#> 
#> ----------------------------------------------------------------------------------------------------
#>  id            LHS               RHS       support   confidence   lift   rule_number   trial_number 
#> ---- ----------------------- ------------ --------- ------------ ------ ------------- --------------
#>  1     Petal.Length <= 1.9      setosa       50        0.9808     2.9         1             1       
#> 
#>  2    Petal.Length > 1.9 &    versicolor     48         0.96      2.9         2             1       
#>       Petal.Length <= 4.9 &                                                                         
#>        Petal.Width <= 1.7                                                                           
#> 
#>  3      Petal.Width > 1.7     virginica      46        0.9583     2.9         3             1       
#> 
#>  4     Petal.Length > 4.9     virginica      46        0.9375     2.8         4             1       
#> ----------------------------------------------------------------------------------------------------

Installation

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

install.packages("tidyrules")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("talegari/tidyrules")

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.