Title: | Process Prediction |
---|---|
Description: | Means to predict process flow, such as process outcome, next activity, next time, remaining time, and remaining trace. Off-the-shelf predictive models based on the concept of Transformers are provided, as well as multiple ways to customize the models. This package is partly based on work described in Zaharah A. Bukhsh, Aaqib Saeed, & Remco M. Dijkman. (2021). "ProcessTransformer: Predictive Business Process Monitoring with Transformer Network" <arXiv:2104.00721>. |
Authors: | Ivan Esin [aut], Gert Janssenswillen [cre], Hasselt University [cph] |
Maintainer: | Gert Janssenswillen <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-10-21 03:32:56 UTC |
Source: | https://github.com/cran/processpredictR |
Confusion matrix for predictions
confusion_matrix(predictions, ...)
confusion_matrix(predictions, ...)
predictions |
|
... |
additional arguments. |
A table
object that can be used for plotting a confusion matrix using plot()
.
Defines the model using the keras functional API. The following 4 process monitoring tasks are defined:
outcome
next_activity
next_time
remaining_time
remaining_trace
remaining_trace_s2s
create_model( x_train, custom = FALSE, num_heads = 4, output_dim_emb = 36, dim_ff = 64, ... )
create_model( x_train, custom = FALSE, num_heads = 4, output_dim_emb = 36, dim_ff = 64, ... )
x_train |
|
custom |
|
num_heads |
A number of attention heads of the |
output_dim_emb |
Dimension of the dense embedding of the |
dim_ff |
Dimensionality of the output space of the feedforward network part of the model ( |
... |
you can pass additional arguments to |
An object of class ppred_model
and list
containing a Transformer model (returned by keras::keras_model()
) and some additional useful metrics.
Creates a vocabulary of activities and outcome labels.
create_vocabulary(processed_df)
create_vocabulary(processed_df)
processed_df |
A preprocessed object of type |
A list
consisting of:
"keys_x"
: list
of activity labels
"keys_y"
: list
of outcome labels (none for tasks "next_time"
and "remaining_time"
)
Utils
get_vocabulary(examples)
get_vocabulary(examples)
examples |
a preprocessed dataset returned by prepare_examples_dt(). |
Calculate the maximum length of a case / number of activities in the longest trace in an event log
max_case_length(processed_df)
max_case_length(processed_df)
processed_df |
A processed dataset of class |
An integer
number of the maximum case length (longest trace) in an event log.
library(processpredictR) library(eventdataR) df <- prepare_examples(patients) max_case_length(df)
library(processpredictR) library(eventdataR) df <- prepare_examples(patients) max_case_length(df)
Calculate number of outputs (target variables)
num_outputs(processed_df)
num_outputs(processed_df)
processed_df |
A processed dataset of class |
an integer
number of outputs for supplying as an argument to a Transformer model, i.e. number of unique labels for a specific process monitoring task.
library(processpredictR) library(eventdataR) df <- prepare_examples(patients) num_outputs(df)
library(processpredictR) library(eventdataR) df <- prepare_examples(patients) num_outputs(df)
Visualize metric
## S3 method for class 'ppred_predictions' plot(x, ...)
## S3 method for class 'ppred_predictions' plot(x, ...)
x |
Data to plot. An object of type |
... |
Additional variables |
A ggplot object, which can be customized further, if deemed necessary.
object of type ppred_examples_df
is a transformed event log returned by prepare_examples_dt()
.
object of type ppred_model
is a list returned by processpredictR::create_model() containing a custom keras functional (transformer) model and some other useful metrics of an event log.
object of type ppred_predictions
is a data.frame with predicted values returned by predict.ppred_model().
log
into a preprocessed format.an event log is converted into a tibble where each row contains a cumulative sequence of activities per case. This sequence will eventually be feeded to the Transformer model's token embedding layer.
prepare_examples( log, task = c("outcome", "next_activity", "next_time", "remaining_time", "remaining_trace", "remaining_trace_s2s"), features = NULL, ... )
prepare_examples( log, task = c("outcome", "next_activity", "next_time", "remaining_time", "remaining_trace", "remaining_trace_s2s"), features = NULL, ... )
log |
|
task |
|
features |
|
... |
additional arguments. |
a preprocessed dataset of class ppred_examples_df
.
library(processpredictR) library(eventdataR) prepare_examples(patients, "next_activity")
library(processpredictR) library(eventdataR) prepare_examples(patients, "next_activity")
Print methods
## S3 method for class 'ppred_model' print(x, ...)
## S3 method for class 'ppred_model' print(x, ...)
x |
|
... |
Additional Arguments. |
prints a Transformer model from a list returned by create_model()
.
Means to predict process flow, such as process outcome, next activity, next time, remaining time, and remaining trace. Off-the-shelf predictive models based on the concept of Transformers are provided, as well as multiple ways to customize the models. This package is partly based on work described in Zaharah A. Bukhsh, Aaqib Saeed, & Remco M. Dijkman. (2021). "ProcessTransformer: Predictive Business Process Monitoring with Transformer Network" arXiv:2104.00721.
Maintainer: Gert Janssenswillen [email protected]
Authors:
Ivan Esin [email protected]
Other contributors:
Hasselt University [copyright holder]
data.frame
.Returns train- and test dataframes as a list.
split_train_test(processed_df, split = 0.7)
split_train_test(processed_df, split = 0.7)
processed_df |
A preprocessed object of type |
split |
|
A list
containing the train- and the test set objects.
library(processpredictR) library(eventdataR) df <- prepare_examples(patients, "next_activity") split_train_test(df, split = 0.8)
library(processpredictR) library(eventdataR) df <- prepare_examples(patients, "next_activity") split_train_test(df, split = 0.8)
User friendly interface to add a keras layer on top of existing model.
stack_layers(object, ...)
stack_layers(object, ...)
object |
a |
... |
functions for adding layers by using functional keras API. For example, |
a list
containing an adapted Transformer model.
ppred_examples_df
Tokenize features and target of a processed ppred_examples_df
object to fit the Transformer model.
tokenize(processed_df)
tokenize(processed_df)
processed_df |
A preprocessed object of type |
A list
of (sequence) tokens and additional numeric
or categorical
features.
Calculate the vocabulary size, i.e. the sum of number of activities, outcome labels and padding keys
vocab_size(processed_df)
vocab_size(processed_df)
processed_df |
A processed dataset of class |
an integer
number of vocabulary size to define the Transformer model.
library(processpredictR) library(eventdataR) df <- prepare_examples(patients) vocab_size(df)
library(processpredictR) library(eventdataR) df <- prepare_examples(patients) vocab_size(df)