Process mining reconstructs how a business process actually runs from the timestamped records your systems already keep. Every case (a purchase order, an invoice, a support ticket) leaves a trail of activities and times in an ERP, CRM or workflow tool, and process mining turns those trails into a map of the real process, checks it against the documented one and shows where cases wait. PM4Py is an open-source Python library for doing this in code; Celonis is one of the best-known commercial platforms, sold by quote, with data connectors, dashboards and automation on top.
Whichever you use, most of the work is building an event log you can trust. Running the algorithms is the quick part.
What process mining tells you
The IEEE Task Force on Process Mining, in its Process Mining Manifesto, splits the field into three kinds of analysis:
- Discovery builds a process model from the event log alone, with no model given in advance.
- Conformance checking compares the log with a model you already have, usually the documented procedure, and finds the cases that deviate.
- Enhancement adds information to the model, most often time (where cases wait, which steps are slow) and resources (who hands work to whom).
The questions it answers are concrete. How many different paths do purchase orders take between creation and payment? How many invoices get paid without being matched to a goods receipt? Where does an order spend most of its time? Which approvals bounce back and forth? Workshops and interviews tell you how people believe the process works. The event log has every case, including the ones nobody mentions.
It helps to place it next to the tools it gets confused with. A BI dashboard counts and sums: orders per week, average days to pay. Process mining cares about sequence, meaning what happened before what in each case. Task mining records what people do on their desktops (clicks, applications, copy and paste) and works inside one person's screen; process mining works on system records across the whole process. Robotic process automation runs steps for you, while process mining tells you which steps deserve automating and, later, whether the automation changed anything.
When it is worth doing
It pays off when a process has volume, crosses several people or systems, and leaves timestamps in a database: purchase-to-pay, order-to-cash, claims, IT tickets, loan applications, patient pathways. It pays off most when someone has a specific question and the authority to change the process once it is answered.
Wait, or skip it, when:
- most of the work happens over email, paper or the phone, so the system only sees the start and the end;
- you handle a few hundred cases a year, which a spreadsheet and a conversation will cover;
- one system already reports how long each stage takes, and that answers your question;
- nobody owns the process, so the findings will have nowhere to go.
Start with one process and one question. A brief like "show us our procurement process" tends to end with an impressive map and no decision. "Why do so many invoices miss their payment term?" has an owner, a number you can measure and a change at the end of it.
The event log is most of the work
An event log has one row per event. Three columns are required: a case ID, an activity name and a timestamp. A resource (the user or system that did the step) and case attributes such as amount, supplier or department make the analysis far more useful.
case_id | activity | timestamp | resource |
|---|---|---|---|
PO-10231 | Create PO | 2026-03-02 09:14 | u017 |
PO-10231 | Approve PO | 2026-03-04 16:40 | u102 |
PO-10231 | Receive goods | 2026-03-11 08:05 | u233 |
PO-10231 | Receive invoice | 2026-03-12 11:30 | system |
PO-10231 | Pay invoice | 2026-04-09 10:00 | system |
Choose the case carefully
The case ID decides what "the process" is. In purchasing you could follow the order, the order line or the invoice, and each gives a different process. Real data rarely lines up one to one: one invoice settles three orders, one order arrives in two deliveries. Squeeze that into a single case ID and events are either copied into several cases, which inflates counts, or dropped.
Object-centric process mining exists for this. Each event can refer to several objects at once (order, item, invoice, delivery), and the OCEL 2.0 standard defines a format for such logs. PM4Py reads and writes OCEL 2.0 files, and Celonis launched object-centric process mining at Celosphere 2022 and followed it with an object-centric data model in 2023. For a first project, follow the object your question is about and remember what that leaves out.
Where the history is kept
Look for tables that record changes: status histories, audit logs, document flow, workflow-engine history. In SAP, the change-document tables CDHDR and CDPOS record who changed which field of which document and when. Salesforce and Dynamics 365 keep field history once field history tracking or auditing is switched on for the fields you need. If a system stores only the current status, the past is gone; switch on change logging now and mine in a few months.
Extraction is usually SQL that reshapes several tables into those four columns. A sketch for a generic purchasing schema:
-- One row per event: case_id, activity, timestamp, resource
SELECT po.po_number AS case_id, 'Create PO' AS activity,
po.created_at AS timestamp, po.created_by AS resource
FROM purchase_orders po
UNION ALL
SELECT h.po_number, 'Approve PO', h.changed_at, h.changed_by
FROM po_status_history h
WHERE h.new_status = 'APPROVED'
UNION ALL
SELECT gr.po_number, 'Receive goods', gr.posted_at, gr.posted_by
FROM goods_receipts gr
UNION ALL
SELECT inv.po_number, 'Receive invoice', inv.received_at, NULL
FROM invoices inv
UNION ALL
SELECT inv.po_number, 'Match invoice', inv.matched_at, NULL
FROM invoices inv
WHERE inv.matched_at IS NOT NULL
UNION ALL
SELECT pay.po_number, 'Pay invoice', pay.paid_at, NULL
FROM payments pay
ORDER BY case_id, timestamp;This assumes one invoice per order. Where that is false, decide what to do (attach the invoice to every order it covers, or follow the invoice instead) before any analysis, because the choice changes every number that follows. If the data has to be copied out of production first, the usual ETL versus ELT trade-offs apply.
Clean it before you mine it
These are the problems to check for, with the symptom that gives each one away:
- Two systems writing local time and UTC put events in the wrong order. A large share of cases with "payment before invoice" is the usual sign.
- Date-only timestamps leave events on the same day without an order, and the algorithm will invent one. Find a finer timestamp, or treat same-day events as unordered.
- A nightly batch job that stamps thousands of events at 02:00 makes that step look instant and the one before it look slow.
- "Approve", "Approved" and "approval_ok" are one activity to a person and three to an algorithm. Map activity names to a fixed list.
- Master data often holds duplicates that nothing in the schema prevents. The hospital HR systems that send staff data to Oplist, a client whose shift-scheduling platform we build, can have more than one record for the same person, so we deduplicate in Oplist instead of trusting the source. In an event log the same problem shows up as one person split into two resources, each with part of the workload.
- Most systems record only when a step finished. The time you see between two steps is then waiting plus work, and you can't separate them.
Before any analysis, take five cases and walk through them with someone who does the work, then reconcile monthly case counts against the source system's own reports. Our post on data quality covers the checks worth automating if the log will be rebuilt regularly.
One more check before you share the log: the resource column usually holds employee IDs, which makes it personal data. Replace IDs with pseudonyms during extraction and keep the mapping table somewhere else, under tighter access. Under the GDPR, pseudonymised data still counts as personal data (Recital 26), so this lowers the risk without taking the log out of scope. Agree in writing what the resource data will be used for. People notice quickly when a process dashboard turns into a league table of employees.
If the log goes to a cloud platform, ask where it will be stored. Personal data sent to a country outside the EEA is an international transfer under Chapter V of the GDPR and needs a basis such as an adequacy decision or standard contractual clauses. Most process questions can be answered without knowing who did the work, so the simplest fix is often to leave the resource column out of the upload and check that the case attributes (customer names, for example) carry no personal data either.
A worked example in PM4Py
PM4Py started at Fraunhofer FIT and is now maintained by its spin-off, Process Intelligence Solutions. It installs with pip install pm4py and needs Python 3.11 or later. We tested the code below with version 2.7.23.11, released in October 2026, on a synthetic purchasing log of 800 orders that we generated for the purpose.
Check the license before you build anything on it. The free version is AGPL-3.0, and the maintainers' licensing page says software that uses it generally has to be published under the AGPL as well, including software people use over a network. If PM4Py will end up inside a product or a service you sell, plan for their commercial license.
Load the CSV and tell PM4Py which column is which:
import pandas as pd
import pm4py
df = pd.read_csv("events.csv") # case_id, activity, timestamp, resource
df["timestamp"] = pd.to_datetime(df["timestamp"], utc=True, format="ISO8601")
log = pm4py.format_dataframe(
df, case_id="case_id", activity_key="activity", timestamp_key="timestamp"
)utc=True reads any timestamp without an offset as UTC. If one of your sources exports local time without an offset, give those rows their real time zone before you combine them (pd.to_datetime(s).dt.tz_localize("Europe/Berlin"), then .dt.tz_convert("UTC")), or you recreate the ordering problem from the checklist above. In zones with daylight saving, a time that falls in the spring-forward gap raises an error; the nonexistent and ambiguous arguments let you decide what happens to those rows.
Variants first
Variants are the cheapest insight in process mining. Each variant is one exact sequence of activities, with the number of cases that followed it:
variants = pm4py.get_variants(log)
print(len(variants), "variants")
for path, n in sorted(variants.items(), key=lambda kv: kv[1], reverse=True)[:10]:
print(n, " > ".join(path))Real logs often have a long tail of variants seen only once or twice. Read the top ten with the process owner and ask, for each one, "is this supposed to happen?"
Discovery: use the Inductive Miner
net, im, fm = pm4py.discover_petri_net_inductive(log, noise_threshold=0.2)The Inductive Miner always returns a sound model (every case can run through to the end, with no deadlocks or dead parts), and with the noise threshold at zero it can replay every case in the log. Raising noise_threshold leaves out infrequent behaviour so the model stays readable. To look at it, call pm4py.view_petri_net(net, im, fm), which needs Graphviz installed. The Alpha Miner is mostly useful for teaching, because noise and short loops break it. The Heuristics Miner copes with messy logs but can return unsound models that some cases can't be replayed on. If you have read about the Fuzzy Miner, that one is in ProM, the Java toolkit from the same research community; PM4Py doesn't include it.
Conformance: two numbers that answer different questions
Write the documented process as a process tree (here a plain sequence), convert it to a Petri net and align every case against it:
sop = pm4py.parse_process_tree(
"->('Create PO', 'Approve PO', 'Receive goods', "
"'Receive invoice', 'Match invoice', 'Pay invoice')"
)
sop_net, sop_im, sop_fm = pm4py.convert_to_petri_net(sop)
fit = pm4py.fitness_alignments(log, sop_net, sop_im, sop_fm)
print(f"log fitness {fit['log_fitness']:.2f}, "
f"{fit['percentage_of_fitting_traces']:.1f}% of cases fit exactly")
per_case = pm4py.conformance_diagnostics_alignments(
log, sop_net, sop_im, sop_fm, return_diagnostics_dataframe=True
)
per_case[~per_case["is_fit"]].to_csv("deviating_cases.csv", index=False)log_fitness measures how much of the logged behaviour the model can replay. percentage_of_fitting_traces is the share of cases that follow the model with no deviation at all. On our test log, log fitness was 0.97 while 79.5% of cases fit exactly. Tell a manager "97% conformance" and they will hear something that isn't true. The per-case file lists every deviating case, which is the first thing an auditor or process owner asks for.
The method matters too. Alignments are exact and get slow on very large logs. Token-based replay is fast and approximate, and by default PM4Py's version leaves activities that aren't in the model out of the fitness calculation. On the same log, fitness_token_based_replay reported 83.5% fitting cases, because 32 orders whose only deviation was an unplanned "Change PO price" step counted as fitting. The lower-level token replay API has a consider_activities_not_in_model_in_fitness parameter; with it switched on, the figure dropped to the alignment result of 79.5%. Report numbers from alignments; fall back to token replay when the log is too big and you know what it overlooks.
Performance: where cases wait
perf, _, _ = pm4py.discover_performance_dfg(log)
slowest = sorted(perf.items(), key=lambda kv: kv[1]["median"], reverse=True)
for (a, b), s in slowest[:5]:
print(f"{a} -> {b}: median {s['median'] / 86400:.1f} days")This gives statistics for the time between each pair of consecutive activities. With completion timestamps only, that time is waiting plus work. The slowest hand-off is the first bottleneck candidate. Before reporting it, split it by supplier, department or amount: a step that is slow for two suppliers is a different problem from a step that is slow for everyone.
How process maps mislead
The directly-follows graph (DFG), one box per activity and an arrow for "was directly followed by", is the default map in most commercial tools. Wil van der Aalst's practitioner's guide to its limitations shows two traps worth knowing before you present one.
First, activities that can happen in any order show up as loops between each other, even when each one happened only once per case. Parallel work looks like rework.
Second, frequency sliders hide activities, and the arrows that remain can then be wrong. In the paper's example, half the cases go a, b, c in two days and half go a, c in ten days, so a is always eventually followed by c and the average flow time is six days. With b filtered out, the 2019 version of Disco tested in the paper showed a followed by c in only half the cases, with a ten-day delay, and the author notes that most commercial tools produce the same map.
So never carry a time or a frequency from a filtered map into a meeting. Compute it from the variant list or the case table, and say which filters were on.
PM4Py, Celonis or another platform
Tool | What it is | Good fit |
|---|---|---|
PM4Py | Python library; free under AGPL-3.0, commercial license on request | Teams that write Python, one-off analyses, mining inside your own data pipelines |
Celonis | Cloud platform with ERP extractors, dashboards, an object-centric data model and automation; priced by quote | Large companies on SAP or Oracle that want to monitor several processes continuously |
Power Automate Process Mining | Process mining inside Microsoft's Power Platform | Organisations already on Microsoft 365, Dynamics and Power BI |
SAP Signavio Process Intelligence | SAP's process mining, part of the Signavio suite | SAP-centric companies that also model processes in Signavio |
UiPath Process Mining | Process mining inside the UiPath automation platform | Companies that already run UiPath bots |
Disco (Fluxicon) | Desktop application that builds process maps from your data | Analysts who want quick maps without writing code |
ProM | Open-source research toolkit with many algorithms as plug-ins | Trying an algorithm PM4Py doesn't have, such as the Fuzzy Miner |
Microsoft publishes list prices. As of October 2026, Power Automate Premium costs $15 per user per month, billed yearly, and includes 50 MB of process-mining storage per license, while the Process Mining add-on is $5,000 per tenant per month for 100 GB. Celonis doesn't publish prices; its pricing page leads to a sales contact.
Our view: begin with PM4Py, or Disco if nobody on the team writes Python, on one process exported once. That costs little beyond an analyst's time, and it tells you whether your systems record enough to answer the question and whether the answer changes anything. Buy a platform when the analysis has to run continuously, across several processes, for business users who will never open a notebook, and when ready-made extractors for your ERP replace months of SQL. Budget for implementation and data engineering on top of the license, since the event log still has to be right.
Running a first project
- Write down the question and the decision it will feed.
- Find the tables and the person who knows them. Pull at least one full business cycle, including a month-end or quarter-end if the process has one.
- Build and check the log as described above, then work through variants, discovery, conformance and waiting times in that order.
- Take two or three findings to the process owner with example case IDs attached, so the discussion is about real orders and not about whether the numbers can be trusted.
- Decide what changes: a rule, a form, a staffing pattern, or an automation. If you automate, mine the log again afterwards to see whether it worked. Our posts on business process automation and RPA cover choosing and building that next step.
- Only then decide whether the analysis should run continuously, which is when a platform license starts to earn its cost.
Frequently asked questions
What is the difference between process mining and data mining?
Data mining looks for patterns in data in general: clusters, correlations, predictions. Process mining is narrower. It works on events grouped into cases and ordered in time, and its output is a process model and measurements on it.
What is the XES format?
XES is the IEEE 1849 standard for storing event logs as XML; its current revision was published in 2023. PM4Py, ProM and Disco all read it. For your own work, a CSV with case, activity and timestamp columns is usually enough.
Does process mining use AI?
The core algorithms (discovery, conformance checking) are not machine learning. Machine learning comes in for predictive monitoring, such as estimating how long an open case will take or whether it will miss its deadline, and vendors now add LLM assistants that answer questions about the data.
If you want help turning your systems' data into an event log you can trust, that extraction and pipeline work is part of our data and AI services.
Related Articles
MLOps Guide: What to Set Up First, and What Can Wait
MLOps gets a model into production and keeps it useful there. Here is the order we'd set it up in, with current MLflow and DVC examples, and what changes for LLM features.
Read More: MLOps Guide: What to Set Up First, and What Can WaitComputer Vision Applications: Where It Works and Where It Struggles
Where computer vision works today, from inspection lines to invoices and medical scans, what makes some applications hard, and when a general vision model saves you training your own.
Read More: Computer Vision Applications: Where It Works and Where It StrugglesAI Agent Development: When You Need One and How to Build It
An AI agent is a language model working in a loop with tools. When you need one, the loop in Python, choosing a framework, keeping it safe, and what each run costs.
Read More: AI Agent Development: When You Need One and How to Build It
