Skip to main content

Package for Multi-Perspective Process Visualization

Project description

mpvis

A Python package for Multi-Perspective Process Visualization of event logs

Index

Installation

This package runs under Python 3.9+, use pip to install.

pip install mpvis

IMPORTANT To render and save generated diagrams, you will also need to install Graphviz

Documentation

This package has three main modules:

  • preprocessing has functionalities for log pruning based on top k variants and manual grouping of log activities.
  • mpdfg to discover and visualize Multi-Perspective Directly-Follows Graphs (DFG)
  • mddrt to discover and visualize Multi-Dimensional Directed-Rooted Trees (DRT)

Event Log Preprocessing

Format event log

Using mpvis.log_formatter you can format your own initial event log with the corresponding column names, based on pm4py standard way of naming logs columns.

The format dictionary to pass as argument to this function needs to have the following structure:

{
    "case:concept:name": <Case Id>, # required
    "concept:name": <Activity Id>, # required
    "time:timestamp": <Timestamp>, # required
    "start_timestamp": <Start Timestamp>, # optional
    "org:resource": <Resource>, # optional
    "cost:total": <Cost>, # optional
}

Each value of the dictionary needs to match the corresponding column name of the initial event log. If start_timestamp, org:resource and cost:total are not present in your event log, you can leave its values as blank strings.

import mpvis
import pandas as pd

raw_event_log = pd.read_csv("raw_event_log.csv")

format_dictionary = {
    "case:concept:name": "Case ID",
    "concept:name": "Activity",
    "time:timestamp": "Complete",
    "start_timestamp": "Start",
    "org:resource": "Resource",
    "cost:total": "Cost",
}

event_log = mpvis.log_formatter(raw_event_log, format_dictionary)

Manual log grouping of activities

Groups specified activities in a process log into a single activity group. Every activity name in activities_to_group needs to be in the event log activity column.

from mpvis import preprocessing

activities_to_group = ["A", "B", "C"]

manual_grouped_log = preprocessing.manual_log_grouping(
    event_log=event_log,
    activities_to_group=activities_to_group,
    group_name="Grouped Activities" # Optional
    )

Log pruning by number of variants

This function filters the event log to keep only the top k variants based on their frequency. Variants are different sequences of activities in the event log.

from mpvis import preprocessing

#k is the number of variants to keep
pruned_log_by_variants = preprocessing.prune_log_based_on_top_variants(event_log, k=3)

Multi-Perspective Directly-Follows Graph (Discovery / Visualization)

Discover Multi Perspective DFG

Discovers a multi-perspective Directly-Follows Graph (DFG) from a log.

from mpvis import mpdfg

(
    multi_perspective_dfg,
    start_activities,
    end_activities,
) = mpdfg.discover_multi_perspective_dfg(
    event_log,
    calculate_cost=True,
    calculate_frequency=True,
    calculate_time=True,
    frequency_statistic="absolute-activity", # or absolute-case, relative-activity, relative-case
    time_statistic="mean", # or sum, max, min, stdev, median
    cost_statistic="mean", # or sum, max, min, stdev, median
)

Filter DFG by activities

Filters activities of a multi-perspective Directly-Follows Graph (DFG) diagram.

from mpvis import mpdfg

activities_filtered_multi_perspective_dfg = mpdfg.filter_multi_perspective_dfg_activities(
    percentage=0.5,
    dfg=multi_perspective_dfg,
    start_activities=start_activities,
    end_activities=end_activities,
    sort_by="frequency",
    ascending=True,
)

Filter DFG by paths

Filters paths of a multi-perspective Directly-Follows Graph (DFG) diagram.

from mpvis import mpdfg

activities_filtered_multi_perspective_dfg = mpdfg.filter_multi_perspective_dfg_paths(
    percentage=0.5,
    dfg=multi_perspective_dfg,
    start_activities=start_activities,
    end_activities=end_activities,
    sort_by="frequency",
    ascending=True,
)

Get the DFG diagram string representation

Creates a string representation of a multi-perspective Directly-Follows Graph (DFG) diagram.

mpdfg_string = mpdfg.get_multi_perspective_dfg_string(
    multi_perspective_dfg,
    start_activities,
    end_activities,
    visualize_frequency=True,
    visualize_time=True,
    visualize_cost=True,
    rankdir="TB", # or BT, LR, RL, etc.
    diagram_tool="graphviz", # or mermaid
)

View the generated DFG diagram

Allows the user to view the diagram in interactive Python environments like Jupyter and Google Colab.

mpdfg.view_multi_perspective_dfg(
    multi_perspective_dfg,
    start_activities,
    end_activities,
    visualize_frequency=True,
    visualize_time=True,
    visualize_cost=True,
    rankdir="TB", # or BT, LR, RL, etc.
)

Save the generated DFG diagram

mpdfg.save_vis_multi_perspective_dfg(
    multi_perspective_dfg,
    start_activities,
    end_activities,
    file_name="diagram",
    visualize_frequency=True,
    visualize_time=True,
    visualize_cost=True,
    format="png", # or pdf, webp, svg, etc.
    rankdir="TB", # or BT, LR, RL, etc.
    diagram_tool="graphviz", # or mermaid
)

Multi-Dimensional Directed-Rooted Tree (Discovery / Visualization)

Discover Multi-Dimensional DRT

Discovers and constructs a multi-dimensional Directly Rooted Tree (DRT) from the provided event log.

This function analyzes an event log and creates a multi-dimensional Directly Rooted Tree (DRT) representing the process model. The DRT is built based on various dimensions such as time, cost, quality, and flexibility, according to the specified parameters.

from mpvis import mddrt

drt = mddrt.discover_multi_dimensional_drt(
    event_log,
    calculate_cost=True,
    calculate_time=True,
    calculate_flexibility=True,
    calculate_quality=True,
    group_activities=False,
    show_names=False
)

Get the DRT diagram string representation

Generates a string representation of a multi-dimensional directly rooted tree (DRT) diagram.

mddrt_string = mddrt.get_multi_dimension_drt_string(
    multi_dimensional_drt,
    visualize_time=True,
    visualize_cost=True,
    visualize_quality=True,
    visualize_flexibility=True
)

View the generated DRT diagram

Allows the user to view the diagram in interactive Python environments like Jupyter and Google Colab.

mddrt.view_multi_dimensional_drt(
    multi_dimensional_drt
    visualize_time=True,
    visualize_cost=True,
    visualize_quality=True,
    visualize_flexibility=True,
    node_measures=["total"], # accepts also "consumed" and "remaining"
    arc_measures=[], # accepts "avg", "min" and "max", or you can keep this argument empty
    format="svg" # Format value should be a valid image extension like 'jpg', 'png', 'jpeq' or 'webp
)

WARNING Not all output file formats of Graphviz are available to display in environments like Jupyter Notebook or Google Colab.

Save the generated DRT diagram

Saves a visualization of a multi-dimensional directly rooted tree (DRT) to a file.

mddrt.save_vis_multi_dimensional_drt(
    multi_dimensional_drt
    file_path="diagram",
    visualize_time=True,
    visualize_cost=True,
    visualize_quality=True,
    visualize_flexibility=True,
    node_measures=["total"], # accepts also "consumed" and "remaining"
    arc_measures=[], # accepts "avg", "min" and "max", or you can keep this argument empty
    format="svg", # or pdf, webp, svg, etc.
)

Examples

Checkout Examples to see the package being used to visualize an event log of a mining process.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpvis-1.0.3.tar.gz (19.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mpvis-1.0.3-py3-none-any.whl (68.6 kB view details)

Uploaded Python 3

File details

Details for the file mpvis-1.0.3.tar.gz.

File metadata

  • Download URL: mpvis-1.0.3.tar.gz
  • Upload date:
  • Size: 19.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for mpvis-1.0.3.tar.gz
Algorithm Hash digest
SHA256 e26079ba46dae02ea4875c6eaed9c8b8d6d28484c64fe76a86bbad942885a83b
MD5 fcd484f25872921124e5d684e398dc4e
BLAKE2b-256 0bb6f8da091eca73c8edb4cc885bbf0545bc1b4450ae8df615c5ff367ca0c131

See more details on using hashes here.

Provenance

The following attestation bundles were made for mpvis-1.0.3.tar.gz:

Publisher: python-publish.yml on nicoabarca/mpvis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mpvis-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: mpvis-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 68.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for mpvis-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1d67bf73ee4c24f1f1f58f2d56e42ec43406b9df21587b8cb2e72d73781f49e8
MD5 7c2e6c75bfd7ec964fe582592e7feb08
BLAKE2b-256 64d6d0e9ec520db67edc485a26a186af8454804d2bd9c68dfcc9bedc407e2ba9

See more details on using hashes here.

Provenance

The following attestation bundles were made for mpvis-1.0.3-py3-none-any.whl:

Publisher: python-publish.yml on nicoabarca/mpvis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page