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

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
)

Get the DFG diagram string representation

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

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,
)

Get the DRT diagram string representation

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

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-0.0.4.tar.gz (11.2 MB view details)

Uploaded Source

Built Distribution

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

mpvis-0.0.4-py3-none-any.whl (68.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mpvis-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b1af4909dc066f15cd26118c93c053c6ce305653d7a155fec2a67511a1f159d6
MD5 07d748eca6c089f82f6fed7b3f1c8414
BLAKE2b-256 6668123001ed9c0fcf1ad80bd26fbbccd26ea418d93bf66ea9391c1454b9b543

See more details on using hashes here.

Provenance

The following attestation bundles were made for mpvis-0.0.4.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-0.0.4-py3-none-any.whl.

File metadata

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

File hashes

Hashes for mpvis-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 22de3ee0d70edab5dcc1283a03597a5e05d314dc8ed40992e37d26479a370210
MD5 3be6cd394d826e913d7ddddfd67d729a
BLAKE2b-256 1e72da8a6540698526fc05b99237d256a3ab2016d7626c6dfc24e2ba796773fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for mpvis-0.0.4-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