# Ad-RuLer: A Novel Rule-Driven Data Synthesis Technique for Imbalanced Classification
## 3 Method
### Ad-RuLer Oversampling Approach  
Figure 1 depicts the entire framework of the Ad-RuLer approach. As can be seen from the figure, the rule extraction process constitutes the core of the system, incorporating two essential steps: New Rule Generation and Dissimilarity Measure. These steps form an interactive process that proceeds until the generation of all candidate rules is complete. Initially, Rule Extraction involves transforming minority class samples into IF-THEN rules. Subsequently, through pairwise comparisons, new rules are continually generated in an iterative process that continues until no further candidate rules emerge. During the Dissimilarity Measure procedure, the Hamming distance is employed to quantify the dissimilarity between rules. The process iteratively constructs new candidate rules by calculating the union of the corresponding sets of extracted rules, generating all candidatesthat meet a predefined dissimilarity threshold \(d\), while the parameter _ratio_ controls the quantity of synthesized rules. These synthesized rules are then reconverted into the minority class samples. If the majority and minority class samples within the data are not yet fully balanced, random sampling techniques are applied to achieve balance among the classes of the synthesized data. The Ad-RuLer method comprises several key procedures: Rule Extraction, Dissimilarity Measure, New Rule Generation, and Balanced Resampling. Below, we provide a more detailed description of each procedure. The pseudocode for the data synthesis process is illustrated in Algorithm 1. **Rule extraction**: Each data instance is treated as an IF-THEN rule, represented as an array of size \(N\). The first \(N-1\) entries are rule antecedents, and the \(N\)th entry is the rule consequent, assigned to the label [14]. The rule extraction process iteratively compares different rules to identify patterns. For instance, the rule \(r=[\{1\},\{3\},\{3\},\text{positive}]\) indicates \"if the first attribute is \(1\) and the second attribute is \(3\), then the assigned label is positive\". Rules are stored in a list and can be accessed via their indices. The rule \(r=[\{1,2,3\},\{5\},\dots,\{7\},\text{positive}]\) means IF \(r[1]=1\) or \(2\) or \(3\) and \(r[2]=5\) and... and \(r[N-1]=7\), THEN the label \(=\) positive. **Dissimilarity measure**: The dissimilarity measure function takes a pair of rules, \(r_{1}\) and \(r_{2}\), with the same class, and if the calculated dissimilarity is less than a user-defined threshold \(d\), it creates a new rule by taking the union of the corresponding sets of the extracted rules. For instance, if \(r_{1}=[\{1\},\{3,5,7\},\text{positive}]\) and \(r_{2}=[\{1,3\},\{7,11\},\text{positive}]\), then \(r_{1,2}=[\{1,3\},\{3,5,7,11\},\text{positive}]\). This procedure proceeds via pairwise comparison and iteration until no new rules can be created, returning all candidate rules that meet the conditions. The \(\mathit{dissimilarity}(r_{1},r_{2})\) is calculated by counting the number of empty intersections between the corresponding sets of the two rules, returning candidate rules that meet the conditions. For example, if \(r_{1}=[\{1\},\{4,5\},\text{positive}]\) and \(r_{2}=[\{1,2\},\{5,6\},\text{positive}]\), then \(\mathit{dissimilarity}(r_{1},r_{2})=0\). If \(r_{1}=[\{1\},\{4,5\},\text{positive}]\) and \(r_{2}=[\{1,2\},\{6\},\text{positive}]\), then \(\mathit{dissimilarity}(r_{1},r_{2})=1\). **New rule generation**: During the rule generation process, any contradictions between rules are first checked, eliminating those with identical parameter values but different labels. In the rule generation function, _ratio_ is a user-defined parameter, with \(ratio\in[0,1]\), which controls the quantity of synthesized rules. It represents that the proportion of the data generated via the candidate rules present in the original data should be greater than or equal to the user-defined value. A \(ratio=1\) signifies that \(100\%\) of the instances included in the candidate rules must be present in the input data to accept the rule.