Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Python Implementation of Decay Replay Mining (DREAM)

License

NotificationsYou must be signed in to change notification settings

Julian-Theis/PyDREAM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyDREAM is a Python implementation of the Decay Replay Mining (DREAM) approach and the corresponding predictive algorithms (NAP and NAPr) similar to the ones described in the paperDecay Replay Mining to Predict Next Process Events and is based onPM4Py. The original Java implementation used for benchmarking can be foundhere. There exists also a ProM pluginhere.

How-To

Please seeexample.py for an end-to-end example.

Prerequisites

PyDREAM requires an event log and a corresponding PNML Petri net file, both imported through PM4Py.

frompm4py.objects.log.importer.xesimportimporterasxes_importerfrompm4py.objects.petri.importerimportimporteraspnml_importerlog=xes_importer.apply('YOUR_EVENTLOG.xes')net,initial_marking,_=pnml_importer.apply("YOURPETRINET.pnml")

Event Logs

The event log must be wrapped into a PyDREAM LogWrapper instance.

frompydream.LogWrapperimportLogWrapperfrompm4py.objects.log.importer.xesimportimporterasxes_importerlog=xes_importer.apply('YOUR_EVENTLOG.xes')log_wrapper=LogWrapper(log)

If you plan on using resources, for example to train a NAPr model, provide the relevant resource identifiers.

log_wrapper=LogWrapper(log,resources=["IDENTIFIER"])

Decay Function Enhancement

The loaded Petri net can be enhanced as described in the paper as described subsequently. AnEnhancedPN instance will automatically detect if a givenLogWrapper objects encompasses resources.

frompydream.EnhancedPNimportEnhancedPNenhanced_pn=EnhancedPN(net,initial_marking)enhanced_pn.enhance(log_wrapper)enhanced_pn.saveToFile("YOURENHANCEDPN.json")

Decay Replay

Timed State Samples through Decay Replay can be obtained by replaying an event log wrapped into anLogWrapper instance on the enhanced Petri net. The function returns two values.First, the resulting Timed State Samples in JSON format that can be saved to file directly. Second, a list of TimedStateSample instances that can be used for further processing. The Timed State Samples will contain resource counters if a givenLogWrapper objects encompasses resources.

importjsonfrompydream.LogWrapperimportLogWrapperfrompydream.EnhancedPNimportEnhancedPNfrompm4py.objects.petri.importerimportimporteraspnml_importerfrompm4py.objects.log.importer.xesimportimporterasxes_importerlog=xes_importer.apply('YOUR_EVENTLOG.xes')log_wrapper=LogWrapper(log)net,initial_marking,_=pnml_importer.import_net("YOURPETRINET.pnml")enhanced_pn=EnhancedPN(net,initial_marking,decay_function_file="YOURENHANCEDPN.json")tss_json,tss_objs=enhanced_pn.decay_replay(log_wrapper=log_wrapper)withopen("timedstatesamples.json",'w')asf:json.dump(tss_json,f)

To replay also resources, calldecay_replay() by listing all resources identifier that should be considered.

log_wrapper=LogWrapper(log,resources=["IDENTIFIER"])tss_json,tss_objs=enhanced_pn.decay_replay(log_wrapper=log_wrapper,resources=["IDENTIFIER"])

Next trAnsition Prediction (NAP)

ANAP orNAPr predictor can be trained in the following way.

frompydream.predictive.nap.NAPimportNAPalgo=NAP(tss_train_file="timedstatesamples.json",tss_test_file="timedstatesamples.json",options={"n_epochs" :100})algo.train(checkpoint_path="model-path",name="MODEL-NAME",save_results=True)

The corresponding model will be stored automatically based on the providedcheckpoint_path andname parameters. The implemented options include:

  • "seed" : int
  • "n_epochs" : str
  • "n_batch_size" : int
  • "dropout_rate" : float
  • "eval_size" : float
  • "activation_function" : str

One can load a trained model from file in the following way.

algo=NAP()algo.loadModel(path="model-path",name="MODEL-NAME")

The following function predicts the next events by returning the raw NAP output and the event names in string format.

frompydream.util.TimedStateSamplesimportloadTimedStateSamplestss_loaded_objs=loadTimedStateSamples("timedstatesamples.json")nap_out,string_out=algo.predict(tss_loaded_objs)

Requirements

PyDREAM is developed for Python 3.7 and is based on PM4Py v2.1.2. NAP and NAPr require tensorflow 2.4.0. The full list of requirements can be found inrequirements.txt.

Remarks

This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the corresponding license for more details.

Citation

@article{theis2019decay,  title={Decay Replay Mining to Predict Next Process Events},  author={Theis, Julian and Darabi, Houshang},  journal={IEEE Access},  volume={7},  pages={119787--119803},  year={2019},  publisher={IEEE}}

[8]ページ先頭

©2009-2025 Movatter.jp