tidy.rpart: Get the rulelist from a rpart model

View source: R/tidy.R

tidy.rpartR Documentation

Get the rulelist from a rpart model

Description

Each row corresponds to a rule

Usage

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

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).

Value

A rulelist object

See Also

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

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

Examples

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)


tidyrules documentation built on June 30, 2024, 1:07 a.m.