Giter VIP home page Giter VIP logo

actionrules's Introduction

Action Rules

License: MIT

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.

actionrules's People

Contributors

lukassykora avatar kliegr avatar dependabot[bot] avatar

Stargazers

 avatar Teele avatar Zoe Duan avatar  avatar  avatar JackYoung avatar Rimantas Zukaitis avatar Bryden Wayne avatar Bjarte M. Østvold avatar Vishal Belsare avatar Mia Bajić avatar  avatar  avatar Aileen Benedict avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  avatar  avatar

actionrules's Issues

ModuleNotFoundError: No module named 'fim'

Hi,

I am currently reproduce experiments of CausalRulesDiscovery, which is implemented based on the actionrules.
However, the error above occurs every time when I execute the files.
Is it possible to substitute another library?
It would be thankful if someone shares idea to resolve this issue.

Kind regards

Bildschirmfoto 2021-11-29 um 15 56 09

Problem installing package on linux

pip install https://test.pypi.org/simple/ actionrules-lukassykora

Gives errror
ERROR: Cannot unpack file /tmp/pip-unpack-26bij12f/simple (downloaded from /tmp/pip-req-build-qor_7uw6, content-type: text/html; charset=UTF-8); cannot detect archive format

pip install -i https://test.pypi.org/simple/ actionrules-lukassykora

Gives errror

Collecting actionrules-lukassykora
Using cached https://test-files.pythonhosted.org/packages/4a/63/c1bf588c34102d80b0c3244cc571d6a1636618a2db77cef28cfe9ff6fec3/actionrules_lukassykora-1.0.18-py3-none-any.whl
Collecting typing (from actionrules-lukassykora)
ERROR: Could not find a version that satisfies the requirement typing (from actionrules-lukassykora) (from versions: none)
ERROR: No matching distribution found for typing (from actionrules-lukassykora)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.