Skip to main content

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

Project description

Action Rules

pypi python Build Status codecov

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

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://lukassykora.github.io/action-rules/notebooks/Example.ipynb

Credits

This package was created with Cookiecutter and the waynerv/cookiecutter-pypackage project template.

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

action_rules-0.0.7.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

action_rules-0.0.7-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file action_rules-0.0.7.tar.gz.

File metadata

  • Download URL: action_rules-0.0.7.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

Hashes for action_rules-0.0.7.tar.gz
Algorithm Hash digest
SHA256 434341a86d6bb0fd3c1a50a176bf8e0e2f84163b4955fbab56b4ed63df29dd2f
MD5 28ce8fd7ccd07c511ff10832c4fcb64c
BLAKE2b-256 9075f6bf9b9a3e786b6bb0e57c7c6e746efbe1993c879536b181905e71b96ab4

See more details on using hashes here.

File details

Details for the file action_rules-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: action_rules-0.0.7-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

Hashes for action_rules-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7b6b30432ab0c4be05fe16ccfadb2277a9eb91b8c4f673e4aa2e7e95becd535b
MD5 6c3b3cbd1b5064f411e3032f6177ce48
BLAKE2b-256 a42cb7bd71e878f13f1a6ac1b21b6d9d81856fcb92019ab1a12715c1cbebf124

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