Skip to main content

Nature-inspired algorithms for Association Rule Mining

Project description


NiaARM - A minimalistic framework for numerical association rule mining.


PyPI Version PyPI - Python Version PyPI - Downloads GitHub license GitHub commit activity Average time to resolve an issue

General outline of the framework

NiaARM is a framework for Association Rule Mining based on nature-inspired algorithms for optimization. The framework is written fully in Python and runs on all platforms. NiaARM allows users to preprocess the data in a transaction database automatically, to search for association rules and provide a pretty output of the rules found. This framework also supports numerical and real-valued types of attributes besides the categorical ones. Mining the association rules is defined as an optimization problem, and solved using the nature-inspired algorithms that come from the related framework called NiaPy.

Detailed insights

The current version includes (but is not limited to) the following functions:

  • loading datasets in CSV format,
  • preprocessing of data,
  • searching for association rules,
  • providing output of mined association rules,
  • generating statistics about mined association rules.

Installation

pip3

Install NiaARM with pip3:

pip3 install niaarm

Usage

Basic example

from niaarm import NiaARM, Dataset
from niapy.algorithms.basic import DifferentialEvolution
from niapy.task import Task, OptimizationType


# load and preprocess the dataset from csv
data = Dataset("datasets/Abalone.csv")

# Create a problem:::
# dimension represents the dimension of the problem;
# features represent the list of features, while transactions depicts the list of transactions
# the following 4 elements represent weights (support, confidence, coverage, shrinkage)
# None defines that criteria are omitted and are, therefore, excluded from the fitness function
problem = NiaARM(data.dimension, data.features, data.transactions, alpha=1.0, beta=1.0)

# build niapy task
task = Task(problem=problem, max_iters=30, optimization_type=OptimizationType.MAXIMIZATION)

# use Differential Evolution (DE) algorithm from the NiaPy library
# see full list of available algorithms: https://github.com/NiaOrg/NiaPy/blob/master/Algorithms.md
algo = DifferentialEvolution(population_size=50, differential_weight=0.5, crossover_probability=0.9)

# run algorithm
best = algo.run(task=task)

# sort rules
problem.sort_rules()

# export all rules to csv
problem.export_rules('output.csv')

For a full list of examples see the examples folder.

Command line interface

niaarm -h
usage: niaarm [-h] -i INPUT_FILE [-o OUTPUT_FILE] -a ALGORITHM [-s SEED]
              [--max-evals MAX_EVALS] [--max-iters MAX_ITERS] [--alpha ALPHA]
              [--beta BETA] [--gamma GAMMA] [--delta DELTA] [--log]
              [--show-stats]

Perform ARM, output mined rules as csv, get mined rules' statistics

options:
  -h, --help            show this help message and exit
  -i INPUT_FILE, --input-file INPUT_FILE
                        Input file containing a csv dataset
  -o OUTPUT_FILE, --output-file OUTPUT_FILE
                        Output file for mined rules
  -a ALGORITHM, --algorithm ALGORITHM
                        Algorithm to use (niapy class name, e. g.
                        DifferentialEvolution)
  -s SEED, --seed SEED  Seed for the algorithm's random number generator
  --max-evals MAX_EVALS
                        Maximum number of fitness function evaluations
  --max-iters MAX_ITERS
                        Maximum number of iterations
  --alpha ALPHA         Alpha parameter. Default 0
  --beta BETA           Beta parameter. Default 0
  --gamma GAMMA         Gamma parameter. Default 0
  --delta DELTA         Delta parameter. Default 0
  --log                 Enable logging of fitness improvements
  --show-stats          Display stats about mined rules

Note: The CLI script can also run as a python module (python -m niaarm ...)

Reference Papers:

Ideas are based on the following research papers:

[1] I. Fister Jr., A. Iglesias, A. Gálvez, J. Del Ser, E. Osaba, I Fister. Differential evolution for association rule mining using categorical and numerical attributes In: Intelligent data engineering and automated learning - IDEAL 2018, pp. 79-88, 2018.

[2] I. Fister Jr., V. Podgorelec, I. Fister. Improved Nature-Inspired Algorithms for Numeric Association Rule Mining. In: Vasant P., Zelinka I., Weber GW. (eds) Intelligent Computing and Optimization. ICO 2020. Advances in Intelligent Systems and Computing, vol 1324. Springer, Cham.

[3] I. Fister Jr., I. Fister A brief overview of swarm intelligence-based algorithms for numerical association rule mining. arXiv preprint arXiv:2010.15524 (2020).

License

This package is distributed under the MIT License. This license can be found online at http://www.opensource.org/licenses/MIT.

Disclaimer

This framework is provided as-is, and there are no guarantees that it fits your purposes or that it is bug-free. Use it at your own risk!

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

niaarm-0.1.2.tar.gz (72.8 kB view details)

Uploaded Source

Built Distribution

niaarm-0.1.2-py3-none-any.whl (76.7 kB view details)

Uploaded Python 3

File details

Details for the file niaarm-0.1.2.tar.gz.

File metadata

  • Download URL: niaarm-0.1.2.tar.gz
  • Upload date:
  • Size: 72.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.10 Linux/5.16.11-100.fc34.x86_64

File hashes

Hashes for niaarm-0.1.2.tar.gz
Algorithm Hash digest
SHA256 97262dafbc23a16f06a727b1a3bcb97ea6ea7c071b15967a790e4f23fdfefc56
MD5 75d2d21ac8d08842e7e920b84d23fbc1
BLAKE2b-256 eb3867f955edaeddb6c1012eb019dfbca1824699d39660699ddb5cd5f1ead368

See more details on using hashes here.

File details

Details for the file niaarm-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: niaarm-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 76.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.10 Linux/5.16.11-100.fc34.x86_64

File hashes

Hashes for niaarm-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b16facd0bc02d7593fb9b7c65e92fcb57c8601d46062847dfc9f6d60d2f43430
MD5 662da4759acfbd232b916bf2607dc5b7
BLAKE2b-256 b3014b7a3926aa9ac2c17975657823f7f1dff0d1457c08744c48c0e5e9cfc1e5

See more details on using hashes here.

Supported by

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