predict.rulelist {tidyrules}R Documentation

predict method for a rulelist

Description

Predicts rule_nbr applicable (as per the order in rulelist) for a row_nbr (per key) in new_data

Usage

## S3 method for class 'rulelist'
predict(object, new_data, multiple = FALSE, ...)

Arguments

object

A rulelist

new_data

(dataframe)

multiple

(flag, default: FALSE) Whether to output all rule numbers applicable for a row. If FALSE, the first satisfying rule is provided.

...

unused

Details

If a row_nbr is covered more than one rule_nbr per 'keys', then rule_nbr appearing earlier (as in row order of the rulelist) takes precedence.

Output Format

Value

A dataframe. See Details.

See Also

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

Examples

model_c5 = C50::C5.0(species ~.,
                     data = palmerpenguins::penguins,
                     trials = 5,
                     rules = TRUE
                     )
tidy_c5 = tidy(model_c5)
tidy_c5

output_1 = predict(tidy_c5, palmerpenguins::penguins)
output_1 # different rules per 'keys' (`trial_nbr` here)

output_2 = predict(tidy_c5, palmerpenguins::penguins, multiple = TRUE)
output_2 # `rule_nbr` is a list-column of integer vectors


[Package tidyrules version 0.2.7 Index]