Prolothar Rule Mining
Algorithms to learn classification and event sequence prediction rules for event sequence datasets such as process logs.
Based on the publication
Boris Wiegand, Dietrich Klakow, and Jilles Vreeken. Discovering Interpretable Data-to-Sequence Generators. In: Proceedings of the 36th AAAI Conference on Artificial Intelligence (AAAI), Virtual Event. 2022, pp. 4237–4244.
Prerequisites
Python 3.11+
Usage
If you want to run the algorithms on your own data, follow the steps below.
Installing
pip install prolothar-rule-mining
Creating or reading a dataset of sequences with metadata
You can create datasets manually by
from prolothar_common.models.dataset import TargetSequenceDataset
from prolothar_common.models.dataset.instance import TargetSequenceInstance
#define a list of categorical variables and a list of numeric variables
dataset = TargetSequenceDataset(['color'],['size'])
# add instances, where each instance has three parts:
# 1. a unique hashable ID (e.g. of type int or str)
# 2. a dictionary with attribute names and attribute values
# 3. a (potentially empty) list or tuple of events of type str
dataset.add_instance(TargetSequenceInstance(
1, {'color': 'red', 'size': 100}, []
))
dataset.add_instance(TargetSequenceInstance(
2, {'color': 'blue', 'size': 42}, ['A', 'B']
))
Alternatively, you can read a dataset from an .arff file:
from prolothar_common.models.dataset import TargetSequenceDataset
with open('dataset.arff', 'r') as f:
dataset = TargetSequenceDataset.create_from_arff(f.read(), 'sequence')
Exemplary .arff file:
@RELATION "TestDataset"
@ATTRIBUTE "color" {"blue","red"}
@ATTRIBUTE "size" NUMERIC
@ATTRIBUTE "sequence" {"[]","[A,B]"}
@DATA
"red",100,"[]"
"blue",42,"[A,B]"
Discovering an Event-flow Graph Using ConSequence
from prolothar_rule_mining.rule_miner.data_to_sequence.consequence import ConSequence
consequence = ConSequence()
rules_model = consequence.mine_rules(dataset)
#make predictions
for instance in dataset:
print('=================')
print(instance.get_target_sequence())
print(rules_model.execute(instance))
#get and print the event flow graph
graph = rules_model.get_event_flow_graph()
graph.plot()
graph.plot(view=False, filepath='path_to_pdf')
#get and print the classification rule at each node
for node, router in rules_model.get_node_router_table().items():
print('===============================')
print(f'rule at node {node}')
print(router.get_rule())
# alternative: print(router.get_rule().to_html())
Development
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Additional Prerequisites
- make (optional)
Compile Cython code
make cython
Running the tests
make test
Deployment
- Change the version in version.txt
- Build and publish the package on pypi by
make clean_package
make package && make publish
- Create and push a tag for this version by
git tag -a [version] -m "describe this version"
git push --tags
Versioning
We use SemVer for versioning.
Authors
If you have any questions, feel free to ask one of our authors:
- Boris Wiegand - boris.wiegand@stahl-holding-saar.de
Metadata
Release files for prolothar-rule-mining 5.0.0
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 | Actions |
|---|---|---|---|---|
| prolothar_rule_mining-5.0.0.tar.gz | 5.9 MB | Without provenance | Details for prolothar_rule_mining-5.0.0.tar.gz |
Release files / prolothar_rule_mining-5.0.0.tar.gz
| Download URL | prolothar_rule_mining-5.0.0.tar.gz |
|---|---|
| Size | 5.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05565d0ba587da80d8f37a151283f71ad0afcdb85c73a945fa48aa59a6504a85
|
|
BLAKE2b-256 checksum How to use checksums |
e3b3bd15c42acf0249ab49b21006ace478fc8e48569bdf89302c740ba6f145a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Security for prolothar-rule-mining 5.0.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.