# Distributed Action-Rule Discovery Based on Attribute Correlation and Vertical Data Partitioning
## 4 Materials and Methods
### Methods for Distributed Action Rule Generation
#### 4.1.1 Vertical Partitioning Based on Attribute Correlation  
The process for this method are shown in Figure 1 and the steps include:  
1. Calculate the correlations between the flexible classification attributes in a given dataset. 2. Perform agglomerative clustering on all of the flexible attributes using correlations among them as the distance measure, resulting in a dendrogram. 3. Iterate through the different levels of the dendrogram, resulting in various sets of our flexible attributes clustered. Extract action rules for each cluster of flexible attributes, each one extended by the same stable attributes. Then, create all possible combinations, taking one action rule from each cluster and checking its support. 4. Determine the best vertical partition of the dataset by comparing the F-scores of the sets of action rules discovered for each partition. The first step is calculating the similarity between flexible attributes in a dataset. Similarity between attributes is calculated differently based on whether the attributes are continuous (numerical) or discrete (categorical). If both attributes are continuous, _Pearson's_\(R\) correlation is used for that purpose. If both are discrete (categorical), we use _Cramer's V_. If one attribute is continuous and the other is discrete, the Correlation Ratio is used. [PERSON]'s correlation coefficient (\(r\)) is a way to measure the similarity between two attributes. It requires that both attributes are quantitative, normally distributed, and also specifically measure a linear relationship [39; 40]. It is defined as follows:  
\[Pearson^{\prime}s\,R=\frac{n\sum xy-(\sum x)(\sum y)}{\sqrt{[n\sum x^{2}-(\sum x)^ {2}][n\sum y^{2}-(\sum y)^{2}]}} \tag{5}\]  
_Cramer's V_ measures the relationship between two nominal features, returning a 0 for no relationship or a 1 for a perfect relationship [39; 40]. \[[PERSON]^{\prime}s\,V=\sqrt{\frac{X^{2}}{n*min(c-1,r-1)}} \tag{6}\]  
where \(X^{2}\) is the chi-square value, \(n\) is the sample size, \(c\) is the number of columns, and \(r\) is the number of rows. We utilized the Dython Python ([[http://shakedzy.xyz/dydthon](http://shakedzy.xyz/dydthon)]([http://shakedzy.xyz/dydthon](http://shakedzy.xyz/dydthon)), accessed on 25 January 2024) library to calculate these associations given the attributes' types (continuous or discrete). To calculate our distance matrix, we use the following:  
\[DistanceMatrix=1-\frac{|associations|+1}{2} \tag{7}\]  
We then performed agglomerative clustering using the distance matrix. Since all the attributes in our examples are categorical, only the _Cramer's_\(V\) measure is used in the definition of a Distance matrix (by \(\left\lvert D\right\rvert\), we mean the absolute value of \(D\)). We utilized the SciPy library ([[https://docs.scipy.org/doc/scipy/index.html](https://docs.scipy.org/doc/scipy/index.html)]([https://docs.scipy.org/doc/scipy/index.html](https://docs.scipy.org/doc/scipy/index.html)), accessed on 25 January 2024) to perform the agglomerative clustering using single linkage and to create our dendrogram. Using this dendrogram, we iterated through to find the clusters at each level, resulting in various clusters of our flexible attributes. For example, if we have attributes \(\{A,B,C,D,E\}\), we may get the following sets of clusters: (1) \(\{A\}\), \(\{B\}\), \(\{C\}\), \(\{D,E\}\), (2) \(\{C\}\), \(\{D,E\}\), \(\{B,A\}\), and (3) \(\{D,E\}\), \(\{B,C,A\}\). Here, attributes \(D\) and \(E\) are closest to each other, \(B\) and \(A\) are next closest to each other, and then \(C\) is the closest to the \(\{B,A\}\) cluster. The last possible level would be to combine \(\{D,E\}\) and \(\{B,C,A\}\) into one cluster of \(\{A,B,C,D,E\}\), but that is not what we need, but so we stop there. In other words, our aim is to break our flexible attributes into smaller groups to work with rather than working with them all at once. A single cluster of all attributes would defeat this purpose and is therefore not used. We then generated action rules for each set of clusters.