Skip to main content

Package implementing decision rules. Includes tools for calculations of various measures and indicators, as well as algorithms for filtering rulesets.

Project description

Decision Rules

Package implementing decision rules. The package allows user to define and process decision rules as Python objects and perform operations on datasets to which these rules apply.

Three types of problems are supported:

  • classification
  • regression
  • survival

Functionalities includes, but is not limited to:

  • serialization and deserialization
  • prediction
  • summary statistics
  • comparison between rules (semantic and syntactic)

Installation

Base package can be installed from PyPi:

pip install decision-rules

Besides the base package, additional dependencies are required to use the ruleset_factories module. To install these extras, run:

pip install decision-rules[ruleset_factories]

You can also just clone the repository and install the package locally:

pip install .

or with the extras:

pip install .[ruleset_factories]

Extras

Ruleset factories

Module for transforming rule-based models into decision-rules rulesets.

Usage

Module expose only a single function ruleset_factory, which is used to convert RuleKit-type rulesets into decision-rules rulesets.

Example:

from rulekit.classification import RuleClassifier

from decision_rules.ruleset_factories import ruleset_factory
from decision_rules.classification.ruleset import ClassificationRuleSet

rule_classifier = RuleClassifier()
rule_classifier.fit(X, y)

ruleset: ClassificationRuleSet = ruleset_factory(
    model=rule_classifier,
    X_train=X,
    y_train=y,
)

A parser for MLRules-type rulesets has also been implemented and can be found under decision_rules.ruleset_factories._factories.classification.MLRulesRuleSetFactory. Its .make method takes a list of lines read from MLRules algorithm output file, the dataset and (optionally) a voting metric to calculate rule weights.

Example:

with open("example_MLRules_output.txt") as file:
    ml_rules_lines = file.readlines()
ruleset: ClassificationRuleSet = MLRulesRuleSetFactory().make(
    ml_rules_lines, X_df, y_df, "Precision"
)

Running tests

To run tests of the base package, please run:

python -m unittest discover ./tests/base_tests

To run tests of the extras modules, please run:

python -m unittest discover ./tests/extras

Similarly, you can run tests of the whole package by running:

python -m unittest discover ./tests

Documentation

Full documentation along with some usage examples can be found here.

License

The software is licensed under the MIT License. See the LICENSE file for details.

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

decision_rules-1.3.1.tar.gz (88.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

decision_rules-1.3.1-py3-none-any.whl (149.6 kB view details)

Uploaded Python 3

File details

Details for the file decision_rules-1.3.1.tar.gz.

File metadata

  • Download URL: decision_rules-1.3.1.tar.gz
  • Upload date:
  • Size: 88.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for decision_rules-1.3.1.tar.gz
Algorithm Hash digest
SHA256 6d6b4860c5dfb44ac9c6852767c7f8985277bed7d63b9a02370ef13665e63b00
MD5 4195eef101a8edac69304c3aa4abc4cd
BLAKE2b-256 4cac90abaf457a4b60dc5a8c49fb258e5b68254cc458cfe3764a52cbde839c41

See more details on using hashes here.

Provenance

The following attestation bundles were made for decision_rules-1.3.1.tar.gz:

Publisher: publish-to-pypi.yml on ruleminer/decision-rules

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file decision_rules-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: decision_rules-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 149.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for decision_rules-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e6b6c58aa9b95432f4aa5c87e5a81d2faccc3ed2d12be343d949c46be3579f8c
MD5 39f90218c7b436357de813f6f8ad486c
BLAKE2b-256 f3662ae75b0800c1bdacbeb046fd620d52f6d2374237b1a132410acfe5795b1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for decision_rules-1.3.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on ruleminer/decision-rules

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page