The package for action rules mining using Action-Apriori (Apriori Modified for Action Rules Mining)..
Project description
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
pip install action-rules
Features
Action Rules API
# 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
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 and the waynerv/cookiecutter-pypackage project template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
action_rules-0.0.15.tar.gz
(14.9 kB
view details)
Built Distribution
File details
Details for the file action_rules-0.0.15.tar.gz
.
File metadata
- Download URL: action_rules-0.0.15.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59d0d55e66bf486c1823da6c3a59750f295a248669b485256a8130e58b80ea58 |
|
MD5 | 8e87080074e534e473cd3dd845181c55 |
|
BLAKE2b-256 | a90063eccf0d78b5f4b88c0de86ebd10f4b1d81a4895e96826c0bcaaedf234f8 |
File details
Details for the file action_rules-0.0.15-py3-none-any.whl
.
File metadata
- Download URL: action_rules-0.0.15-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4a01b9cf2b86e68e7eb2339e5449e00f8aee2743373ade166955c7f5cb30261 |
|
MD5 | c3de21f1b1cbcb3c5c35ccc68280b2d8 |
|
BLAKE2b-256 | 61b343b2959a9a6b044cc855b1a6fcd61e5133cc8352d12588a4bd8b2e3526c6 |