Association Rule Mining (ARM) & Apriori
Association Rule Mining is an unsupervised machine learning technique used to discover interesting relationships, frequent patterns, or associations among sets of items in transaction databases. It is often referred to as "Market Basket Analysis."
The core algorithm used in ARM is the Apriori Algorithm. Apriori works on the principle that "if an itemset is frequent, then all of its subsets must also be frequent." It scans the dataset iteratively to build increasingly larger itemsets, discarding any combinations that do not meet a minimum frequency threshold. Once frequent itemsets are found, it generates "Rules" (If condition A happens, then condition B happens).
ARM relies on three primary metrics to evaluate rules:
Support: The frequency of the rule in the dataset (how often items A and B appear together).
Confidence: The reliability of the rule (if A happens, what is the probability B also happens?).
Lift: The ratio of the observed support to that expected if A and B were independent. A Lift > 1 means the items are positively correlated; they appear together more often than by random chance.
Preparing Transactional Data
ARM requires a highly specific data format: purely unlabeled transactional data, typically structured as a list of comma-separated items with no column headers.
Because my original dataset contained continuous quantitative variables (GDP and Military Spending percentage), I had to use a process called Discretization (Binning). Using Python's pd.qcut(), I divided GDP and Military Spending into three equal-sized categorical bins: Low, Medium, and High. I then stripped away all labels (like Country name and specific Year) and combined the newly binned categories with Region and Historical Period. The result is a pure transaction file where each row acts as a "shopping basket" of economic conditions for a given year.
Below is a snapshot of the discretized dataset:
Code Implementation
The ARM analysis was performed in Python using the mlxtend package, which houses the TransactionEncoder, apriori, and association_rules modules. The transaction data was one-hot encoded, allowing the Apriori algorithm to identify frequent itemsets.
Code: https://github.com/rileythejones/-CUBoulder-DS-CSCI-5612-Project/blob/main/ProjectModuleTwo.ipynb
Results and Thresholds
For this analysis, I utilized specific thresholds to ensure the rules were meaningful without overwhelming the algorithm. I set the Minimum Support threshold to 0.05 (5%), meaning a combination of conditions had to occur in at least 5% of all recorded country-years. I set the Minimum Confidence threshold to 0.50 (50%), meaning the rule must be true at least half the time it is triggered.
Network Visualization
Below is a directed network graph visualizing the Top 15 rules sorted by Lift. The arrows indicate the direction of the rule (Antecedent ---> Consequent).
What I Learned Regarding the Topic:
The Association Rule Mining analysis revealed fascinating, automated confirmations of post-Soviet geopolitical dynamics. Because ARM operates blindly on unlabelled transactions, it didn't "know" which countries were involved, only the conditions that existed.
By looking at the highest Lift and Confidence rules, we learn that the condition of Region: Baltics is strongly associated with GDP_High and Mil_Low. Conversely, the rules show that Transitional Chaos (the 1990s) is heavily associated with GDP_Low.
Most importantly for our topic, the algorithm successfully learned the "Guns vs. Butter" trade-off purely from association patterns: baskets containing Mil_High (high military burden) almost never contained GDP_High. This confirms our overarching hypothesis that the remnants of the Soviet military-industrial complex acted as an anchor, weighing down the economic recovery of the nations that maintained it.