## 2 Methodology
### Association Rule Mining and Apriori Algorithm  
Association rule mining refers to the discovery of valuable correlation information and knowledge rules from data sets. The Apriori algorithm is the most classic algorithm for mining association rules. Suppose \(I\ =\ \big{\{}i_{1},\ \ i_{2},\ \ \cdots,\ \ i_{m}\big{\}}\) is an item set, each element \(i_{m}\) of which is called an item, and the item set of length \(k\) is called \(k-itemset\). A subset of item set \(I\) can form a transaction, and multiple transactions can form a transaction database \(T\ =\ \big{\{}t_{1},\ \ t_{2},\ \ \cdots,\ \ t_{n}\big{\}}\). Suppose \(X\) and \(Y\) are two item sets in the transaction database whose intersection is empty, that is, \(X\subset T,Y\subset T\) and \(X\cap Y=\varnothing\). These two item sets can be denoted by \(X\Rightarrow Y\) and if there is an association rule the former item \(X\) denotes the condition of the association rule and the latter item \(Y\) denotes the conclusion of the association rule. To better measure the performance of the mined association rules, three indicators need to be used: support, confidence and lift. Their definitions are as follows:  
Support is the probability that \(X\) and \(Y\) occur together in the transaction database \(T\). Support indicates the importance of association rule \(X\Rightarrow Y\) in the total data:  
\[S_{X\Rightarrow Y}\ =\ \frac{|T(X\cup Y)|}{|T|} \tag{9}\]  
Confidence is the probability that \(Y\) will occur if \(X\) is included. Confidence expresses the validity of the association rule \(X\Rightarrow Y\):  
\[C_{X\Rightarrow Y}\ =\ \frac{|T(X\cup Y)|}{|T(X)|} \tag{10}\]Lift is the ratio of the confidence to the occurrence probability of the later term \(Y\) in the transaction database \(T\). Lift indicates the strength of the correlation, and the larger the lift, the stronger the correlation:  
\[L_{X\Rightarrow Y}\ =\ \frac{|T(X\cup Y)|}{|T(X)|}/\frac{|T(Y)|}{|T|} \tag{11}\]  
where \(|T(X\cup Y)|\) represents the number of item sets \(X\) and \(Y\) appearing in the transaction database \(T\) at the same time. \(|T|\) represents the number of transactions in the transaction database \(T\). \(|T(X)|\) and \(|T(Y)|\) represent the number of item sets \(X\) or \(Y\) appearing in the transaction database \(T\), respectively.  
The minimum support \(min\_supp\) and minimum confidence \(min\_conf\) need to be specified as thresholds in association rule mining. If the support of an item set is greater than \(min\_supp\), then this item set is called frequent item set. If the support and confidence of an association rule are greater than the \(min\_supp\) and \(min\_conf\), then this rule is called a strong association rule. The specific flow of the Apriori algorithm is shown in Figure 1 and described in detail as follows:  
Step 1: Iterate through all the transactions in the transaction database \(T\) and count the number of each item and calculate the support. The items with the support greater than \(min\_supp\) are deleted to generate the frequent 1-item set \(L_{1}\).  
Step 2: Generate candidate 2-item set for \(L_{1}\) by joining and pruning operations, calculate the support of each item in the candidate 2-item set and also filter according to the \(min\_supp\) to get the frequent 2-item set \(L_{2}\). Repeat this process until the candidate \(k-itemset\) is empty, thus obtaining the frequent \(k-itemset\).  
Step 3: Calculate the confidence of each \(L_{k}\) separately, and output the association rules with confidence greater than \(min\_conf\).