Following is the supplementary material for the article "Predictive Business Process Monitoring with LSTM Neural Networks" by Niek Tax, Ilya Verenich, Marcello La Rosa and Marlon Dumas.
The code provided in this repository can be readily used to perform the following predictive tasks:
- Prediction of the next type of activity to be executed in a running process instance
- Prediction of the timestamp of the next type of activity to be executed
- Prediction of the continuation of a running instance, i.e. its suffix
- Prediction of the remaining cycle time of an instance
The scripts trains a Long Short Term Memory (LSTM)-based predictive model using the data about historical, i.e. completed process instances. Next, the models are evaluated on running, i.e. incomplete instances.
Python 2. Additionally, the following Python libraries are required to run the code: keras (as a backend, you need either theano or tensorflow), unicodecsv, numpy, jellyfish, sklearn, matplotlib, h5py.
Note you might need the latest version of keras to run the code. Install it as:
pip install git+git://github.com/fchollet/keras.git
The tool assumes the input is a complete log of all traces in the CSV format wherein the first column is a case ID, then activity name or ID and finally the activity timestamp. Then, this input log is temporally split on 66% (training set) vs 34% (test set), and on the test set the tool evaluates prediction performance for every size of a partial trace, e.g a test trace cut at the 2nd event, the same trace cut at the 3rd event and so on, along all four prediction tasks. We provide sample datasets, including those used in the paper, in the data folder.
This script trains a two-layer LSTM model with one shared layer on one of the data files in the data folder of this repository (by default, on the helpdesk event log). To change the input file to another one from the data folder, indicate its name in line 46. It is recommended to run this script on GPU, as recurrent networks are quite computationally intensive.
This script takes as input the LSTM or RNN weights found by
train.py and predicts the next event and its relative timestep for a partial trace. Change the path in line 176 of this script to point to the h5 file with LSTM or RNN weights generated by train.py. As an example, we provide the file model_89-1.50.h5 with one of the trained models
This script predicts the continuation of a partial trace, i.e. its suffix, until its completion.
This script evaluates the performance of the next event prediction (not the whole suffix). It takes the output of
evaluate_suffix_and_remaining_time.py as input, therefore, the latter needs to be executed first
- If you receive an error UnicodeEncodeError: 'ascii' codec can't encode character u'\xa7' in position 0: ordinal not in range(128), make sure you are using the latest version of the jellyfish package (0.5.6 should work fine)