The tidy_corels() function converts your dataframe into the text file format corels::corels() expects and returns a list of useful R objects.

tidy_corels(df, label_cols, value_delim = "_", ...)

Arguments

df

The dataframe to generate rules from. Applies the function corels::corels().

label_cols

The two columns in df that represent the label. Corels expects two columns representing each class. Consider using recipes::step_dummy() to convert outcome to two columns.

value_delim

the delimiter to mark where the value of the 0/1 binary feature appears in the column name. Default value is underscore "_" as this is used by recipes::step_dummy() when creating dummy columns.

...

Set any of the arguments imported from corels::corels(). The following arguments are fixed by tidy_corels(): rules_file and labels_file (both generated from the dataframe supplied to the df argument), log_dir (set as your current working directory), verbosity_policy (set as "minor").

Details

The function returns your dataframe with the corels rules applied by adding the column "corels_label".

Returns the Corels rules from the console output of corels::corels().

Returns those rules converted to data.table::fifelse() code (corels_rules_DT).

Returns a dataframe of only the true label, the columns with their value if they are used by the rules (i.e. if the value is not used it will be NA), and the corels classification applied to your dataframe (alluvial_df). This dataframe is intended to be used in an easyalluvial plot https://github.com/erblast/easyalluvial/blob/master/README.md.

Returns a dataframe of the peformance of each rule in the order of Corels rules (rule_performance_df).

Returns two dataframes (sankey_edges_df and sankey_nodes_df) to create a sankey network diagram of the corels rules https://christophergandrud.github.io/networkD3/#sankey.

All variables must contain 0 or 1. Consider using recipes::step_dummy() to convert categorical variables to dummy columns. If variable is continous (e.g. age), consider using recipes::step_discretize() before recipes::step_dummy().

The names of the two outcome columns in label_cols argument must end in 0 and 1.

Consider using recipes::step_integer(recipes::all_outcomes(), zero_based = TRUE) to convert outcome values to 0/1 before using recipes::step_dummy() to create the two outcome columns Corels requires.

To apply the corels rules created to a new dataframe, see predict_corels.

Examples: https://billster45.github.io/tidycorels/