Learn R Programming

tidyrules (version 0.2.7)

tidy.rpart: Get the rulelist from a rpart model

Description

Each row corresponds to a rule

Usage

# S3 method for rpart
tidy(x, ...)

Value

A rulelist object

Arguments

x

rpart::rpart model

...

Other arguments (currently unused)

Details

For rpart rules, one should build the model without ordered factor variable. We recommend you to convert ordered factor to factor or integer class.

For rpart::rpart classification model:

  • Output columns are: rule_nbr, LHS, RHS, support, confidence, lift.

  • The rules are sorted in this order: desc(confidence), desc(lift), desc(support).

For rpart::rpart regression(anova) model:

  • Output columns are: rule_nbr, LHS, RHS, support.

  • The rules are sorted in this order: desc(support).

See Also

rulelist, tidy, augment, predict, calculate, prune, reorder

Other Core Tidy Utility: tidy(), tidy.C5.0(), tidy.cubist()

Examples

Run this code
model_class_rpart = rpart::rpart(Species ~ ., data = iris)
tidy(model_class_rpart)

model_regr_rpart = rpart::rpart(Sepal.Length ~ ., data = iris)
tidy(model_regr_rpart)

Run the code above in your browser using DataLab