Metadata-Version: 2.4
Name: decision_rules
Version: 1.9.2
Summary: Package implementing decision rules. Includes tools for calculations of various measures and indicators, as well as algorithms for filtering rulesets.
Author: Cezary Maszczyk, Dawid Macha, Adam Grzelak, Bartosz Piguła
Author-email: cezary.maszczyk@emag.lukasiewicz.gov.pl
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=1.5
Requires-Dist: pydantic>=2.0
Requires-Dist: scipy>=1.11
Requires-Dist: scikit-learn>=1.1
Requires-Dist: imbalanced-learn>=0.10
Requires-Dist: typeguard>=4.3
Requires-Dist: packaging>=14.1
Provides-Extra: visualization
Requires-Dist: matplotlib>=3.5.0; extra == "visualization"
Requires-Dist: seaborn>=0.13.2; extra == "visualization"
Requires-Dist: pyvis>=0.2.2; extra == "visualization"
Requires-Dist: plotly>=5.0.0; extra == "visualization"
Provides-Extra: rulekit
Requires-Dist: rulekit>=2.1.21; extra == "rulekit"
Provides-Extra: cn2
Requires-Dist: Orange3>=3.35.0; extra == "cn2"
Provides-Extra: ruleset-factories
Requires-Dist: rulekit>=2.1.21; extra == "ruleset-factories"
Requires-Dist: Orange3>=3.35.0; extra == "ruleset-factories"
Dynamic: author
Dynamic: author-email
Dynamic: description
Dynamic: description-content-type
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# 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](https://pypi.org/project/decision-rules/):
```
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:
```python
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:
```python
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](https://ruleminer.github.io/decision-rules/).

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