pat_dara: Divergent Association Ranking Analysis

View source: R/pat_dara.R

pat_daraR Documentation

Divergent Association Ranking Analysis

Description

Rank attribute values whose ordering diverges between the dataset and discovered rules.

Usage

pat_dara(
  data,
  rules,
  rhs_attr,
  rhs_value = NULL,
  attributes = NULL,
  rule_weight = NULL
)

Arguments

data

Reference data frame.

rules

Tidy rule data frame produced by pat_rules_tidy().

rhs_attr

Right-hand-side attribute used by the mined rules.

rhs_value

Optional right-hand-side value used to restrict data.

attributes

Optional attributes to compare. Defaults to common columns in data and rules.

rule_weight

Optional numeric column in rules used as rule frequency instead of one count per rule.

Details

DARA compares two value-frequency orderings for each explanatory attribute: the ordering in a reference dataset, optionally restricted to a right-hand-side value, and the ordering in a table of association rules. The right-hand-side attribute is required so it can be excluded from explanatory divergence. The returned counter c increases for values that are more prominent in rules than in the reference data and decreases for values that are less prominent in rules.

Value

A list of per-attribute data frames with columns value, dataset, rules, and c.

References

Baroni, L., Salles, R., Salles, S., Guedes, G., Porto, F., Bezerra, E., Barcellos, C., Pedroso, M., & Ogasawara, E. (2020). An analysis of malaria in the Brazilian Legal Amazon using divergent association rules. Journal of Biomedical Informatics, 108, 103512.

The canonical implementation is maintained in the Python pydaltoolbox port; this is a backport of it.

Examples

if (requireNamespace("arules", quietly = TRUE)) {
  data("AdultUCI", package = "arules")
  data <- as.data.frame(AdultUCI)
  data <- data[, c("workclass", "education", "marital-status", "occupation", "income")]
  pm <- fit(pat_apriori(target = "rules", supp = 0.05, conf = 0.6, rhs = "income=small"), data)
  rules <- pat_rules_tidy(discover(pm, data), transactions = data, item_columns = colnames(data))
  ranking <- pat_dara(data, rules, rhs_attr = "income", rhs_value = "small")
  ranking[["marital-status"]]
}

daltoolbox documentation built on Nov. 23, 2026, 9:08 a.m.