simplify_ruleset: Remove redundant rules and rule components

View source: R/Rule_building.R

simplify_rulesetR Documentation

Remove redundant rules and rule components

Description

Removes whole rules or components of the rules whose removal do not decrease the total number of positive matches found by applying the rules in the original data set.

Usage

simplify_ruleset(ruleset, target_vec, target_data)

Arguments

ruleset

A rule set as generated by generate_rule_selection_set().

target_vec

A vector of labels.

target_data

A DTM with a number of rows as the elements in rules.

Details

The suggested approach is apply this function on the output of generate_rule_selection_set() after manual review of the proposed rules.

Value

A data frame with the preserved rules, the redundant terms removed by the rules, the number of positive and negative (absolute and cumulative) records identified by the rules in the target_data and the position of these records in the target_data.

Examples

## Not run: 
candidate_queries <- readRDS(file.path("Sessions", "Session1", "rule_data.rds"))

Target <- candidate_queries$DTM$Target
SpecificDTM <- candidate_queries$SpecificDTM

simplified_rules <- file.path("Sessions", "Session1", "Selected_rules.xlsx") %>%
  import_data() %>%
  simplify_ruleset(target_vec = Target, target_data = SpecificDTM) %>%
  pull(rule)

## End(Not run)

bakaburg1/BaySREn documentation built on March 30, 2022, 12:16 a.m.