Metadata-Version: 2.1
Name: rule_mining_algs
Version: 0.1.0
Summary: The package contains a few selected association rule mining algorithms.
Author-email: Josef Würf <sepp2357@yahoo.de>
License: MIT License
        
        Copyright (c) 2022 JosWrf
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: repository, https://github.com/JosWrf/rule_mining_algs
Keywords: Association Rule Mining
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# Repository for Assocation Rule Mining Algorithms

Several algorithms for mining association rules have been implemented in this repository.

NOTE: The algorithms are implemented in pure Python which makes them rather slow.

## Different Algorithms thus far

- AIS
- Apriori
- FP-Growth
- h-Clique (all-confidence pushed into Apriori-algorithm)
- Quantitative Association Rules
- AClose
- Minimal Non-redundant rules
- Rule Generation for apriori-like Algorithms
- Brute-Force Mining of Classification Rules
- Clustering to find intervals for numeric attributes
- Evolutionary Algorithm to Discover Itemsets (GAR)
- Evolutionary Algorithm to Discover Rules with fixed consequent (GAR-PLUS)

## Datasets

- store_data.csv: [Store data](https://user.informatik.uni-goettingen.de/~sherbold/store_data.csv)
- agaricus-lepiota.data: [Mushroom dataset](https://archive.ics.uci.edu/ml/datasets/mushroom)

## Build and Run models

- Transformers: static_discretization(equi-depth/width partitioning of numeric attributes),
  cluster_interval_data(birch clustering to find intervals for numeric attributes)
- Itemset_Miners: see [Algorithms](#Different-Algorithms-thus-far) section
- Rule_Miners: generate_rules(Standard algorithm to generate rules from itemsets),
  min_redundant_rules(only usable with a_close itemset miner)

---

**Example for a dataset with a single attribute**

```python
from algs.models import StandardMiner
from algs.data import load_store_data

data_df = load_store_data() # Load store dataset
# Choose model
m = StandardMiner()
# Set parameters for the algorithms
m.set_args(m.itemset_miner, {"min_support": 0.005})
m.set_args(m.rule_miner, {"min_conf": 0.5})
# Run the algorithm on the dataset
output = m.run(data_df)
```

**Example for a DB containing several categorical attributes**

```python
from algs.data import load_shroom_data
from algs.quantitative import static_discretization
from algs.rule_gen import get_classification_rules

shrooms = load_shroom_data()
mine_quant = StandardMiner(static_discretization)
names = {name: 0 for name in shrooms.columns}
# Set arguments for transformer, itemset and rule miner
mine_quant.set_args(mine_quant.transformer, {"discretization": names})
mine_quant.set_args(mine_quant.itemset_miner, {"min_support": 0.15})
mine_quant.set_args(mine_quant.rule_miner, {"min_conf": 0.65})
rules = mine_quant.run(shrooms)
# Post processing step to obtain rules having only the label in the consequent
classification_rules = get_classification_rules(rules, "label")
```
