Metadata-Version: 2.1
Name: action-rules
Version: 0.0.13
Summary: The package for action rules mining using Action-Apriori (Apriori Modified for Action Rules Mining)..
Home-page: https://github.com/lukassykora/action-rules
License: MIT
Author: Lukas Sykora
Author-email: lukas.sykora@vse.cz
Requires-Python: >=3.9,<4.0
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Provides-Extra: dev
Provides-Extra: doc
Provides-Extra: test
Requires-Dist: black (>=24.4.2,<25.0.0) ; extra == "test"
Requires-Dist: bump2version (>=1.0.1,<2.0.0) ; extra == "dev"
Requires-Dist: click (==8.0.1)
Requires-Dist: flake8 (>=7.0.0,<8.0.0) ; extra == "test"
Requires-Dist: flake8-docstrings (>=1.7.0,<2.0.0) ; extra == "test"
Requires-Dist: isort (>=5.13.2,<6.0.0) ; extra == "test"
Requires-Dist: mkdocs (>=1.6.0,<2.0.0) ; extra == "doc"
Requires-Dist: mkdocs-autorefs (>=1.0.1,<2.0.0) ; extra == "doc"
Requires-Dist: mkdocs-include-markdown-plugin (>=6.1.1,<7.0.0) ; extra == "doc"
Requires-Dist: mkdocs-material (>=9.5.25,<10.0.0) ; extra == "doc"
Requires-Dist: mkdocs-material-extensions (>=1.3.1,<2.0.0)
Requires-Dist: mkdocstrings (>=0.25.1,<0.26.0) ; extra == "doc"
Requires-Dist: mkdocstrings-python (>=1.10.3,<2.0.0)
Requires-Dist: mypy (>=1.10.0,<2.0.0) ; extra == "test"
Requires-Dist: pandas (>=2.2.2,<3.0.0)
Requires-Dist: pip (>=24.0,<25.0) ; extra == "dev"
Requires-Dist: pre-commit (>=3.7.1,<4.0.0) ; extra == "dev"
Requires-Dist: pytest (>=8.2.1,<9.0.0) ; extra == "test"
Requires-Dist: pytest-cov (>=5.0.0,<6.0.0) ; extra == "test"
Requires-Dist: toml (>=0.10.2,<0.11.0) ; extra == "dev"
Requires-Dist: tox (>=4.15.0,<5.0.0) ; extra == "dev"
Requires-Dist: twine (>=5.1.0,<6.0.0) ; extra == "dev"
Requires-Dist: virtualenv (>=20.26.2,<21.0.0) ; extra == "dev"
Description-Content-Type: text/markdown

# Action Rules

[![pypi](https://img.shields.io/pypi/v/action-rules.svg)](https://pypi.org/project/action-rules/)
[![python](https://img.shields.io/pypi/pyversions/action-rules.svg)](https://pypi.org/project/action-rules/)
[![Build Status](https://github.com/lukassykora/action-rules/actions/workflows/dev.yml/badge.svg)](https://github.com/lukassykora/action-rules/actions/workflows/dev.yml)
[![codecov](https://codecov.io/gh/lukassykora/action-rules/branch/main/graphs/badge.svg)](https://codecov.io/github/lukassykora/action-rules)

The package for action rules mining using Action-Apriori (Apriori Modified for Action Rules Mining).

* Documentation: <https://lukassykora.github.io/action-rules>
* GitHub: <https://github.com/lukassykora/action-rules>
* PyPI: <https://pypi.org/project/action-rules/>
* Free software: MIT

## Installation

```commandline
pip install action-rules
```

## Features

### Action Rules API

```python
# Import Module
from action_rules import ActionRules
import pandas as pd

# Get Data
transactions = {'Sex': ['M', 'F', 'M', 'M', 'F', 'M', 'F'],
                'Age': ['Y', 'Y', 'O', 'Y', 'Y', 'O', 'Y'],
                'Class': [1, 1, 2, 2, 1, 1, 2],
                'Embarked': ['S', 'C', 'S', 'C', 'S', 'C', 'C'],
                'Survived': [1, 1, 0, 0, 1, 1, 0],
                }
data = pd.DataFrame.from_dict(transactions)
# Initialize ActionRules Miner with Parameters
stable_attributes = ['Age', 'Sex']
flexible_attributes = ['Embarked', 'Class']
target = 'Survived'
min_stable_attributes = 2
min_flexible_attributes = 1  # min 1
min_undesired_support = 1
min_undesired_confidence = 0.5  # min 0.5
min_desired_support = 1
min_desired_confidence = 0.5  # min 0.5
undesired_state = '0'
desired_state = '1'
# Action Rules Mining
action_rules = ActionRules(min_stable_attributes, min_flexible_attributes, min_undesired_support,
                           min_undesired_confidence, min_desired_support, min_desired_confidence, verbose=False)
# Fit
action_rules.fit(
    data,
    stable_attributes,
    flexible_attributes,
    target,
    undesired_state,
    desired_state,
)
# Print rules
for action_rule in action_rules.get_rules().get_ar_notation():
    print(action_rule)
# Print rules (pretty notation)
for action_rule in action_rules.get_rules().get_pretty_ar_notation():
    print(action_rule)
# JSON export
print(action_rules.get_rules().get_export_notation())
```

### Action Rules CLI

```commandline
action-rules --min_stable_attributes 2 --min_flexible_attributes 1 --min_undesired_support 1 --min_undesired_confidence 0.5 --min_desired_support 1 --min_desired_confidence 0.5 --csv_path 'data.csv' --stable_attributes 'Sex, Age' --flexible_attributes 'Class, Embarked' --target 'Survived' --undesired_state '0' --desired_state '1' --output_json_path 'output.json'
```

## Jupyter Notebook Example

<https://github.com/lukassykora/action-rules/blob/main/notebooks/Example.ipynb>

## Credits

This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and
the [waynerv/cookiecutter-pypackage](https://github.com/waynerv/cookiecutter-pypackage) project template.

