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

Package can be installed from PyPi:

pip install decision-rules

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

pip install .

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.9.2.tar.gz (115.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.9.2-py3-none-any.whl (191.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: decision_rules-1.9.2.tar.gz
  • Upload date:
  • Size: 115.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for decision_rules-1.9.2.tar.gz
Algorithm Hash digest
SHA256 cf90b1dfac051485cc26e8f67755c7511cd62c7b8180b8abfa164cb1f56b6326
MD5 3f00f4d0e7ec8b764c6a0a1c0f7972ea
BLAKE2b-256 728c23c5163853f09abc5c031b6eccb4e065ed0c350c23e28bd296f6a62eeb07

See more details on using hashes here.

Provenance

The following attestation bundles were made for decision_rules-1.9.2.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.9.2-py3-none-any.whl.

File metadata

  • Download URL: decision_rules-1.9.2-py3-none-any.whl
  • Upload date:
  • Size: 191.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for decision_rules-1.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9be9a2d92488a960650a317dcc3aca3751499136594c5110cf1bc432879eaca1
MD5 a95032e00ac52dca43fdf023958230c8
BLAKE2b-256 17d19c4c42e9b2adc46fba1f9bee1f55716b26de20dd3e8fff3627e1cee26231

See more details on using hashes here.

Provenance

The following attestation bundles were made for decision_rules-1.9.2-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