parse_rules | R Documentation |
Converts association rules into a normalized representation for downstream layout/rendering. Accepts either: - a 'data.frame' with **required** columns 'Antecedent', 'Consequence', 'Support', 'Confidence', 'Fitness', or - a native 'niarules' rules object (which is exported to CSV internally via 'niarules::write_association_rules_to_csv()' and then parsed).
The output separates **items** from **rules** and uses stable **0-based** item identifiers suitable for cross-language use.
parse_rules(arules = NULL)
arules |
A 'data.frame' with columns 'Antecedent', 'Consequence', 'Support', 'Confidence', 'Fitness', **or** a 'niarules' rules object. |
**Input requirements** - 'Antecedent', 'Consequence': character encodings of itemsets per rule. - 'Support', 'Confidence', 'Fitness': numeric metrics; 'Fitness' is interpreted as the **lift-like** metric and is exposed as 'lift' in the returned 'rules'.
When 'arules' is not a 'data.frame', the function requires the **niarules** package at runtime to serialize the rules to CSV. Missing required columns trigger an error.
**Output schema** - 'items' ('data.frame'): 'item_id' (integer, **0-based**), 'label', 'feature', 'kind', 'category_value', 'lo', 'hi', 'incl_low', 'incl_high', 'op', 'label_long', 'label_short'. - 'rules' ('data.frame'): 'rule_id', 'support', 'confidence', 'lift', 'lhs_item_ids' (list of integer vectors; **0-based ids**), 'rhs_item_ids' (list of integer vectors; **0-based ids**), 'antecedent_length', 'consequent_length'.
**Indexing note** 'item_id' values are **0-based** for stability across languages. In R, convert to 1-based with 'items$item_id + 1L' if needed.
A list with components: - 'items': 'data.frame' describing unique items, - 'rules': 'data.frame' describing association rules.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.