Skip to main content

Action Rules Mining Tool.

Project description

Action-Apriori (Apriori Modified for Action Rules Mining)

License: MIT

Installation

The Action-Apriori script needs the following libraries:

  • itertools (built-in module in python)
  • copy (built-in module in python)
  • collections (built-in module in python)
  • pandas (1.3.4)

The tested Python version is: 3.9.7

The action_apriori function can be called:

import action_rules as ar
import pandas as pd
# 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)
# Parameters
stable_attributes = ['Sex','Age']
flexible_attributes = ['Class','Embarked']
target = 'Survived'
wanted_change_in_target = [0, 1]
min_stable_attributes = 2
min_flexible_attributes = 1 #min 1
min_unwanted_support = 1
min_unwanted_confidence = 0.5 #min 0.5
min_wanted_support = 2
min_wanted_confidence = 0.5 #min 0.5
# Action Rules Mining
action_rules = ar.action_apriori(
    data, 
    stable_attributes, 
    flexible_attributes, 
    target, 
    wanted_change_in_target,
    min_stable_attributes , 
    min_flexible_attributes, 
    min_unwanted_support, 
    min_unwanted_confidence, 
    min_wanted_support, 
    min_wanted_confidence, 
    True) #verbose
# Print rules
for action_rule in action_rules:
    print(action_rule)
# Print rules with action rules notation
for action_rule in action_rules:
    print(ar.get_ar_notation(action_rule, target))
# Print rules with export notation
print(ar.get_export_notation(action_rules, target))

The output: ation rule with notation:

[(Sex: F)  (Age: Y)  (Class: 2  1)]  [Survived: 0  1], support of undesired part: 1, confidence of undesired part: 1.0, support of desired part: 2, confidence of desired part: 1.0

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.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

action_rules-0.0.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: action_rules-0.0.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for action_rules-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e20b85ec67e07c37deca4bf33dd87121913696492136f654e960e7b97d7eff7b
MD5 0ed711111f6c25c5b8e8ed04e5486eb0
BLAKE2b-256 8ee34ab25b8a6bffea2d96feb3edbf20fc9a1620f371063adbffe2e27b874d9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for action_rules-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 413f712a2b70c28319637e8e744c1e5af8e938f4b8b78bf6aa012784a19ea7a5
MD5 95fceca674c50a3e1a58c11b7ad3f718
BLAKE2b-256 7f94d2f6f15d3f51fc78d1f32e94925a59e1e36ec00114ee1afe3774b545bccc

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