Skip to main content

An implementation of the Aerial neurosymbolic association rule mining algorithm from tabular datasets.

Project description

pyaerial: scalable association rule mining


Python Versions PyPI Version Downloads Build Status Documentation Status License GitHub Stars DOI

📥 Install | 🚀 Quick Start | ✨ Features | 📚 Documentation | 📋 Releases | 📄 Cite | 🤝 Contribute | 🔑 License

PyAerial finds human-readable IF-THEN rules in tabular data:

IF smoking = yes AND exercise = never    THEN blood_pressure = high   (confidence 0.87, support 0.29)
IF pressure = low AND flow_rate = high   THEN pipe_leakage = yes      (confidence 0.93, support 0.11)
IF education = masters AND age = 30-40   THEN income = >50K           (confidence 0.82, support 0.17)

It is the Python implementation of Aerial, a scalable neurosymbolic association rule miner: an under-complete Autoencoder learns a compact representation of the data, and rules are extracted from the trained model. This avoids the rule explosion and execution time problems of exhaustive miners (Apriori, FP-Growth, ECLAT), making rule mining practical on large datasets such as health records, retail baskets, and sensor data, wherever you want interpretable patterns next to black-box models.

Learn more about the architecture, training, and rule extraction in our paper: Neurosymbolic Association Rule Mining from Tabular Data


Why PyAerial?

PyAerial Exhaustive miners (e.g., Mlxtend, SPMF)
Execution time on large data 100-1000x faster, also on CPU Grows steeply with columns and thresholds
Number of rules Concise, high-quality set with full data coverage Rule explosion (easily millions)
Input format pandas DataFrame, one-hot encoding handled internally Manual one-hot encoding or custom text formats
Rule quality metrics Calculated automatically (support, confidence, Zhang's metric, ...) Requires extra steps
Item constraints, classification rules Built-in Limited or unavailable
GPU support Optional Not available

For comprehensive benchmarks against Mlxtend, SPMF and other ARM tools, see our software paper: PyAerial: Scalable association rule mining from tabular data (SoftwareX, 2025)

PyAerial performance comparison

Execution time comparison across datasets of varying sizes. PyAerial scales linearly while traditional methods (e.g., Mlxtend, SPMF) exhibit exponential growth.


Installation

pip install pyaerial

Note: Examples in the documentation use ucimlrepo to fetch sample datasets. Install it to run the examples:

pip install ucimlrepo

Data Requirements: PyAerial works with categorical data. Numerical columns must be discretized first, using the built-in discretization module. There is no need to one-hot encode your data; PyAerial handles that automatically.


Quick Start

Or try it directly in your browser: Open In Colab

Basic Association Rule Mining

from aerial import model, rule_extraction
from ucimlrepo import fetch_ucirepo

# Load a categorical tabular dataset
breast_cancer = fetch_ucirepo(id=14).data.features

# Train an autoencoder on the loaded table
trained_autoencoder = model.train(breast_cancer)

# Extract association rules with quality metrics calculated automatically
result = rule_extraction.generate_rules(trained_autoencoder, min_rule_frequency=0.1, min_rule_strength=0.8)

print(f"Overall statistics: {result['statistics']}\n")
print(f"Sample rule: {result['rules'][0]}")

Output:

Overall statistics: {
    "rule_count": 15,
    "average_support": 0.448,
    "average_confidence": 0.881,
    "average_coverage": 0.860,
    "data_coverage": 0.923,
    "average_zhangs_metric": 0.318
}

Sample rule: {
    "antecedents": [{"feature": "inv-nodes", "value": "0-2"}],
    "consequent": {"feature": "node-caps", "value": "no"},
    "support": 0.702,
    "confidence": 0.943,
    "zhangs_metric": 0.69,
    "rule_coverage": 0.744
}

Interpretation: When inv-nodes is between 0-2, there's 94.3% confidence that node-caps equals no, covering 70.2% of the dataset.

Quality metrics explained:

  • Support: Frequency of the rule in the dataset (how often the pattern occurs)
  • Confidence: How often the consequent is true when antecedent is true (rule reliability)
  • Zhang's Metric: Correlation measure between antecedent and consequent (-1 to 1; positive values indicate positive correlation)
  • Rule Coverage: Proportion of transactions containing the antecedents
  • Data Coverage (in statistics): Overall proportion of the dataset covered by at least one rule

Rules are plain dictionaries, so working with them is straightforward:

for rule in result['rules']:
    antecedents = " AND ".join(f"{a['feature']}={a['value']}" for a in rule['antecedents'])
    consequent = f"{rule['consequent']['feature']}={rule['consequent']['value']}"
    print(f"IF {antecedents} THEN {consequent} (support: {rule['support']:.2f}, conf: {rule['confidence']:.2f})")

Working with Numerical Data

For datasets with numerical columns, use PyAerial's built-in discretization methods:

from aerial import model, rule_extraction, discretization
from ucimlrepo import fetch_ucirepo

# Load a numerical dataset (e.g., Iris)
iris = fetch_ucirepo(id=53).data.features

# Discretize numerical columns into categorical bins
# Before: sepal_length = 5.1, 4.9, 7.0, ...  After: sepal_length = (4.8, 5.5], (4.8, 5.5], (6.4, 7.9], ...
iris_discretized = discretization.equal_frequency_discretization(iris, n_bins=3)

# Train and extract rules as usual
trained_autoencoder = model.train(iris_discretized, epochs=10)
result = rule_extraction.generate_rules(trained_autoencoder, min_rule_frequency=0.1)

Eight discretization methods are available: unsupervised (equal-frequency, equal-width, k-means, quantile, custom bins) and supervised (entropy-based, ChiMerge, decision tree), each documented with academic references in the User Guide.

More Recipes

Goal How Details
Focus mining on features of interest generate_rules(model, features_of_interest=["age", {"menopause": "premeno"}]) Item constraints
Classification rules (class label as consequent) generate_rules(model, target_classes=["Class"]) Classification rules
Keep only high-quality rules generate_rules(model, filter_min_confidence=0.7, filter_min_support=0.1) Parameter guide
Frequent itemsets instead of rules generate_frequent_itemsets(model) API reference
Antecedents of unlimited length generate_rules(model, max_antecedents=None) Parameter guide
Visualize rules Via NiaARM User guide

Can't get the results you're looking for?

Note on Parameter Names: The parameters min_rule_frequency and min_rule_strength correspond to ant_similarity and cons_similarity in the original Aerial and PyAerial papers.


Features

Rule mining

  • Scalable association rule mining without rule explosion, with full data coverage
  • Frequent itemset mining with the same neural approach
  • Item constraints (features of interest) and classification rules (target classes)
  • Quality metrics calculated automatically: support, confidence, Zhang's metric, lift, conviction, Yule's Q, interestingness, leverage

Data handling

  • Direct pandas DataFrame input; one-hot encoding handled internally
  • Eight discretization methods for numerical columns (unsupervised and supervised)

Performance

  • Fast on CPU; optional GPU acceleration for very large datasets
  • Post-filters (filter_min_confidence, filter_min_support) for high-quality rule sets

Customization and integration

  • Customizable Autoencoder architecture and training (epochs, learning rate, batch size, masking window)
  • Rule visualization via NiaARM; interpretable inference via imodels

How Aerial Works

Aerial employs a three-stage neurosymbolic pipeline:

1. Data Preparation. Categorical data is one-hot encoded while tracking feature relationships; numerical columns are pre-discretized. The encoded values form the input vectors of the Autoencoder.

2. Autoencoder Training. An under-complete Autoencoder is trained with a masking mechanism: each batch randomly corrupts a subset of features to a uniform "unknown" distribution, and the network learns to reconstruct them from the remaining unmasked features. Masking mirrors the antecedent to consequent query pattern used during rule extraction, an improvement over the Gaussian-noise-based denoising of the original Aerial+ paper.

3. Rule Extraction. Rules are extracted by querying the trained Autoencoder with test vectors:

  1. Test vectors are created with equal probabilities across categories
  2. Specific feature values are marked as antecedents while others remain at baseline
  3. Forward runs through the network produce implication probabilities
  4. Rules are extracted when implication probabilities exceed the rule frequency and strength thresholds
  5. Antecedent combinations are searched with an FP-Growth-style growth strategy: only combinations whose estimated frequency passes the threshold are extended further, so forward runs scale with the number of frequent combinations rather than all possible combinations (max_antecedents=None mines antecedents of unlimited length)
  6. Quality metrics (support, confidence, coverage, Zhang's metric, etc.) are calculated automatically using vectorized operations

Aerial+ replaces the counting operation of classical rule mining with the Autoencoder's implication probabilities, so in principle the search strategy of any rule miner can run on top of it. PyAerial adopts FP-Growth's, as it is among the fastest rule miners.

Rule extraction example

Example: Rule extraction process using weather and beverage features

Aerial pipeline

Complete three-stage pipeline: data preparation → training → rule extraction

For the architecture, theoretical foundations, and experimental results, see How Aerial Works in the documentation and the paper.


Documentation

Read the full documentation on ReadTheDocs | Release notes on GitHub Releases


Citation

If you use PyAerial in your work, please cite our research and software papers:

@InProceedings{pmlr-v284-karabulut25a,
  title         = {Neurosymbolic Association Rule Mining from Tabular Data},
  author        = {Karabulut, Erkan and Groth, Paul and Degeler, Victoria},
  booktitle     = {Proceedings of The 19th International Conference on Neurosymbolic Learning and Reasoning},
  pages         = {565--588},
  year          = {2025},
  editor        = {H. Gilpin, Leilani and Giunchiglia, Eleonora and Hitzler, Pascal and van Krieken, Emile},
  volume        = {284},
  series        = {Proceedings of Machine Learning Research},
  month         = {08--10 Sep},
  publisher     = {PMLR},
  url           = {https://proceedings.mlr.press/v284/karabulut25a.html}
}

@article{pyaerial,
  title         = {PyAerial: Scalable association rule mining from tabular data},
  journal       = {SoftwareX},
  volume        = {31},
  pages         = {102341},
  year          = {2025},
  issn          = {2352-7110},
  doi           = {https://doi.org/10.1016/j.softx.2025.102341},
  author        = {Erkan Karabulut and Paul Groth and Victoria Degeler},
}

Contact

For questions, suggestions, or collaborations: Erkan Karabulut, e.karabulut@uva.nl or erkankkarabulut@gmail.com


Contribute

Contributions are welcome: report bugs or suggest features by opening an issue, improve the documentation, or submit a pull request on GitHub.

Contributors

Made with contrib.rocks.


License

This project is licensed under the MIT License; see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyaerial-1.1.0.tar.gz (15.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyaerial-1.1.0-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file pyaerial-1.1.0.tar.gz.

File metadata

  • Download URL: pyaerial-1.1.0.tar.gz
  • Upload date:
  • Size: 15.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyaerial-1.1.0.tar.gz
Algorithm Hash digest
SHA256 3d99b4453bba8b4e98f303bed8453fa9fb6b8882308bfff58c81c2171815c2ea
MD5 882b67a21271db57c76bb790a0d36daa
BLAKE2b-256 b738b83e4bef75668c879334414daaa3ed23c9d10b6dd6e2c1a3cb7d7c4ce149

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyaerial-1.1.0.tar.gz:

Publisher: release.yml on DiTEC-project/pyaerial

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyaerial-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyaerial-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyaerial-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fb1ce0ef9c3225f681445e1477f7b4a0b1a38c37a14323ee6eedb64fd10ac45c
MD5 306b92697880f8531561e39f5853459d
BLAKE2b-256 e3173a9d20818d639389bfab0b6bcaca549f0132d1bb405c5370c8428b3b9f7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyaerial-1.1.0-py3-none-any.whl:

Publisher: release.yml on DiTEC-project/pyaerial

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page