All Projects → Julian-Theis → PyDREAM

Julian-Theis / PyDREAM

Licence: GPL-3.0 license
Python Implementation of Decay Replay Mining (DREAM)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to PyDREAM

The-Purchase-and-Redemption-Forecast-Challenge-baseline
天池“资金流入流出预测——挑战baseline”的解决方案,线上效果143.5
Stars: ✭ 78 (+254.55%)
Mutual labels:  data-mining, prediction
Evilize
Parses Windows event logs files based on SANS Poster
Stars: ✭ 24 (+9.09%)
Mutual labels:  events, eventlogs
Simod
Simod is a tool for automated BPS model discovery
Stars: ✭ 24 (+9.09%)
Mutual labels:  processmining, process-mining
data-exploration-with-apache-drill
Data Exploration with Apache Drill
Stars: ✭ 25 (+13.64%)
Mutual labels:  data-mining
kalend
React calendar component with support for multiple views and events
Stars: ✭ 135 (+513.64%)
Mutual labels:  events
xforest
A super-fast and scalable Random Forest library based on fast histogram decision tree algorithm and distributed bagging framework. It can be used for binary classification, multi-label classification, and regression tasks. This library provides both Python and command line interface to users.
Stars: ✭ 20 (-9.09%)
Mutual labels:  data-mining
website-to-json
Converts website to json using jQuery selectors
Stars: ✭ 37 (+68.18%)
Mutual labels:  data-mining
sst-core
SST Structural Simulation Toolkit Parallel Discrete Event Core and Services
Stars: ✭ 82 (+272.73%)
Mutual labels:  discrete-event
vsSolutionBuildEvent
🎛 Event-Catcher with variety of advanced Actions to service projects, libraries, build processes, runtime environment of the Visual Studio, MSBuild Tools, and …
Stars: ✭ 66 (+200%)
Mutual labels:  events
xgboost-smote-detect-fraud
Can we predict accurately on the skewed data? What are the sampling techniques that can be used. Which models/techniques can be used in this scenario? Find the answers in this code pattern!
Stars: ✭ 59 (+168.18%)
Mutual labels:  data-mining
kriptomist
Fundamental cryptocurrency analysis
Stars: ✭ 29 (+31.82%)
Mutual labels:  prediction
talksearch
🎤 An interactive search experience for video titles and transcripts
Stars: ✭ 24 (+9.09%)
Mutual labels:  events
GA-BP
基于遗传算法的BP网络设计,应用背景为交通流量的预测
Stars: ✭ 102 (+363.64%)
Mutual labels:  prediction
2018
Webend v4.5.26
Stars: ✭ 24 (+9.09%)
Mutual labels:  events
blinkist-m4a-downloader
Grabs all of the audio files from all of the Blinkist books
Stars: ✭ 100 (+354.55%)
Mutual labels:  data-mining
commons.openshift.org
Repository for OpenShift Commons Community Site
Stars: ✭ 31 (+40.91%)
Mutual labels:  events
Apriori-and-Eclat-Frequent-Itemset-Mining
Implementation of the Apriori and Eclat algorithms, two of the best-known basic algorithms for mining frequent item sets in a set of transactions, implementation in Python.
Stars: ✭ 36 (+63.64%)
Mutual labels:  data-mining
Recurrent-Neural-Network-for-BitCoin-price-prediction
Recurrent Neural Network (LSTM) by using TensorFlow and Keras in Python for BitCoin price prediction
Stars: ✭ 53 (+140.91%)
Mutual labels:  prediction
Medium-Stats-Analysis
Exploring data and analyzing metrics for user-specific Medium Stats
Stars: ✭ 27 (+22.73%)
Mutual labels:  data-mining
event
An event dispatching library for PHP
Stars: ✭ 19 (-13.64%)
Mutual labels:  events

PyDREAM

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 paper Decay Replay Mining to Predict Next Process Events and is based on PM4Py. The original Java implementation used for benchmarking can be found here. There exists also a ProM plugin here.

How-To

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

Prerequisites

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

from pm4py.objects.log.importer.xes import importer as xes_importer
from pm4py.objects.petri.importer import importer as pnml_importer

log = 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.

from pydream.LogWrapper import LogWrapper
from pm4py.objects.log.importer.xes import importer as xes_importer

log = 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. An EnhancedPN instance will automatically detect if a given LogWrapper objects encompasses resources.

from pydream.EnhancedPN import EnhancedPN

enhanced_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 an LogWrapper 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 given LogWrapper objects encompasses resources.

import json
from pydream.LogWrapper import LogWrapper
from pydream.EnhancedPN import EnhancedPN
from pm4py.objects.petri.importer import importer as pnml_importer
from pm4py.objects.log.importer.xes import importer as xes_importer

log = 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)
with open("timedstatesamples.json", 'w') as f:
        json.dump(tss_json, f)

To replay also resources, call decay_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)

A NAP or NAPr predictor can be trained in the following way.

from pydream.predictive.nap.NAP import NAP

algo = 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 provided checkpoint_path and name 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.

from pydream.util.TimedStateSamples import loadTimedStateSamples

tss_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 in requirements.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}
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].