Learn R Programming

daltoolbox (version 1.3.787)

pat_dara: 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
)

Value

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

Arguments

data

Reference data frame.

rules

Tidy rule data frame produced by pat_dara_rules() or 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.

Examples

Run this code
if (requireNamespace("arules", quietly = TRUE)) {
  data("AdultUCI", package = "arules")
  data <- as.data.frame(AdultUCI)
  data <- data[, c("workclass", "education", "marital-status", "occupation", "income")]
  rules <- pat_dara_rules(data, rhs = "income=small", supp = 0.05, conf = 0.6)
  ranking <- pat_dara(data, rules, rhs_attr = "income", rhs_value = "small")
  ranking[["marital-status"]]
}

Run the code above in your browser using DataLab