Action Rules
Action Rules (actionrules) is an implementation of Action Rules from Classification Rules algorithm described in
Dardzinska, A. (2013). Action rules mining. Berlin: Springer.
If you use this package, please cite:
Sýkora, Lukáš, and Tomáš Kliegr. "Action Rules: Counterfactual Explanations in Python." RuleML Challenge 2020. CEUR-WS. http://ceur-ws.org/Vol-2644/paper36.pdf
GIT repository
https://github.com/lukassykora/actionrules
Installation
pip install actionrules-lukassykora
Jupyter Notebooks
- Titanic It is the best explanation of all possibilities.
- Telco A brief demonstration.
- Ras Based on the example in (Ras, Zbigniew W and Wyrzykowska, ARAS: Action rules discovery based on agglomerative strategy, 2007).
- Attrition High-Utility Action Rules Mining example.
Example 1
Get data from csv. Get action rules from classification rules. Classification rules have confidence 55% and support 3%. Stable part of action rule is "Age". Flexible attributes are "Embarked", "Fare", "Pclass". Target is a Survived value 1.0. No nan values. Use reduction tables for speeding up. Minimal 1 stable antecedent Minimal 1 flexible antecedent
from actionrules.actionRulesDiscovery import ActionRulesDiscovery
actionRulesDiscovery = ActionRulesDiscovery()
actionRulesDiscovery.read_csv("data/titanic.csv", sep="\t")
actionRulesDiscovery.fit(stable_attributes = ["Age"],
flexible_attributes = ["Embarked", "Fare", "Pclass"],
consequent = "Survived",
conf=55,
supp=3,
desired_classes = ["1.0"],
is_nan=False,
is_reduction=True,
min_stable_attributes=1,
min_flexible_attributes=1,
max_stable_attributes=5,
max_flexible_attributes=5)
actionRulesDiscovery.get_action_rules()
The output is a list where the first part is an action rule and the second part is a tuple of (support before, support after, action rule support) and (confidence before, confidence after, action rule confidence).
Example 2
Get data from pandas dataframe. Get action rules from classification rules. Classification rules have confidence 50% and support 3%. Stable attributes are "Age" and "Sex". Flexible attributes are "Embarked", "Fare", "Pclass". Target is a Survived that changes from 0.0 to 1.0. No nan values. Use reduction tables for speeding up. Minimal 1 stable antecedent Minimal 1 flexible antecedent
from actionrules.actionRulesDiscovery import ActionRulesDiscovery
import pandas as pd
dataFrame = pd.read_csv("data/titanic.csv", sep="\t")
actionRulesDiscovery = ActionRulesDiscovery()
actionRulesDiscovery.load_pandas(dataFrame)
actionRulesDiscovery.fit(stable_attributes = ["Age", "Sex"],
flexible_attributes = ["Embarked", "Fare", "Pclass"],
consequent = "Survived",
conf=50,
supp=3,
desired_changes = [["0.0", "1.0"]],
is_nan=False,
is_reduction=True,
min_stable_attributes=1,
min_flexible_attributes=1,
max_stable_attributes=5,
max_flexible_attributes=5)
actionRulesDiscovery.get_pretty_action_rules()
The output is a list of action rules in pretty text form.
Metadata
Release files for actionrules-lukassykora 1.1.27
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| actionrules-lukassykora-1.1.27.tar.gz | 18.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| actionrules_lukassykora-1.1.27-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.5 kB
Release files / actionrules-lukassykora-1.1.27.tar.gz
| Download URL | actionrules-lukassykora-1.1.27.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be16bef1c69191ccc9a7840ae9decafd09f73cfb1a3dda81c3618abfce99bf3e
|
|
BLAKE2b-256 checksum How to use checksums |
5806eee417a3786be86efc5119bf3b79d5f7608073d77e53366b20cf8297c01e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.7
|
Release files / actionrules_lukassykora-1.1.27-py3-none-any.whl
| Download URL | actionrules_lukassykora-1.1.27-py3-none-any.whl |
|---|---|
| Size | 20.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c413e9f1a86d2db44b39ec6b0ad7400ad92f99770f7c942e94185c501e165bd9
|
|
BLAKE2b-256 checksum How to use checksums |
8df2f2c2fe1e5a6d561123351a7753801eb02e9468a2bc02e92327ab9c0584c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.7
|
Security for actionrules-lukassykora 1.1.27
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.