Skip to content

Systems and records

Workflow data sampling: catching rare branches random samples miss

By SourceX Editorial · Updated

9 sections

Short answer

Reconstruct complete cases first, then define each branch by the decisive event that marks it, such as a rejection, override, rework loop or cancellation. Stratify cases by branch, give every rare branch a fixed floor or take all of its cases, spread the remaining budget across common branches, and record each stratum's weight. Reconcile branch counts to source totals so the sample can be reweighted to the real mix.

System export

Workflow data sampling

This page covers workflow data sampling: catching rare branches random samples miss.Illustrative

Key takeaways

  • A random draw returns exception paths at their population share, which often means one case or none.
  • Validate case reconstruction before counting branches; flattening, clocks and window rules all move cases between branches.
  • Define each stratum by a decisive event, not by full variant, so strata stay large enough to draw from.
  • Give each uncommon path a floor or take all of its cases, and record a weight for every stratum.
  • Report branch findings unweighted and population figures weighted, and keep low-confidence cases labeled.

How do you sample rare workflow branches that random sampling can miss?

Sample by branch, not by case. Rebuild each case from its events, assign it to exactly one branch using a written rule, count the branches against the source system's totals, and then draw a stratified sample in which every rare branch gets a minimum number of cases or all of its cases if it has fewer than that minimum.

The common branches still get most of the budget, so the sample keeps showing what normal work looks like. Each stratum carries a weight equal to its population count divided by its sample count, which lets anyone reading the sample recover the true mix of branches when they need population-level figures.

This matters most when the people evaluating a workflow sample care about exceptions. An approval that was overridden, an invoice rejected and resubmitted, or an order canceled after approval is where a workflow shows judgment. Those cases are also the ones a simple random sample is most likely to leave out.

Why a simple random sample hides the branches buyers ask about

A random sample returns each branch in roughly its population share, so a branch that covers a fraction of a percent of cases is expected to appear about once, or not at all, in a few hundred cases. Process mining tools sample this way by default. The pm4py library's sample_cases function, for example, randomly samples a given number of cases from an event log.

Ordinary stratification does not fix the problem on its own. Proportional stratification keeps each class at its population share; scikit-learn describes its StratifiedShuffleSplit as preserving the percentage of samples for each class, and it raises an error when a class has only one member. That protects common classes from sampling noise but leaves a rare branch exactly as rare as it was.

Variant-based shortcuts make it worse. pm4py's coverage filter illustrates the logic: with 1,000 cases split 500, 400 and 100 across three variants and a 40 percent minimum coverage, only the first two variants are kept. Filters like this are useful for discovering the main process, and they are exactly the wrong step when the rare paths are the point.

Rebuilding complete cases before you count branches

Branch counts are only as good as the case reconstruction under them, so validate the case first. A case needs a stable identifier, a single clock or a documented mapping between clocks, a defined start and end, and a rule for events that belong to more than one business object.

That last rule is where most workflow logs go wrong. A systematic review of object-centric process mining describes three problems that appear when a log is flattened to one case notion: deficiency, where events fall outside every case; convergence, where one event is copied into several cases, as when one invoice covers several orders; and divergence, where several instances of the same activity pile into one case. Each one changes branch counts. The OCEL 2.0 specification is one way to avoid forcing that choice, because it records relationships between events and objects and between objects directly.

Time windows cause a quieter error. pm4py's time filter distinguishes keeping events inside a window, keeping only traces fully contained in it, and keeping traces that intersect it. Rare branches are often long-running, so a contained-only extract drops them disproportionately, while an intersecting extract keeps them with their beginning or end cut off.

Rebuilding complete cases before you count branches
CheckFailure it catchesEffect on branch countsFix before sampling
Case identifier is stable across systemsTicket IDs reissued after a migration or mergeTwo cases merge into one false branchMap old to new IDs and keep both on the case
Single clock or documented offsetsServer time in one system, local time in anotherEvents reorder; a rework loop appears or vanishesConvert to UTC and record the source zone per system
Object relationships keptAn invoice covering several ordersConvergence duplicates events across casesUse an object-centric log or a written allocation rule
Window rule statedLong cases cut at the extract boundaryLong-running exception branches undercountedExtract intersecting cases and flag truncated ones
Source totals reconciledFilters or joins silently dropping recordsBranch shares no longer match the systemMatch case counts by month to a system report
Terminal state definedOpen cases treated as finishedCancellations and late reversals miscountedExclude or flag cases still open at extract time

The branch stratified sampling plan

Work through these steps in order and keep the output of each one with the sample; the plan is the evidence that the sample was drawn fairly. Steps 1 to 4 build the sampling frame, steps 5 to 7 draw the sample, and steps 8 and 9 make it reusable.

The branch stratified sampling plan
StepWhat to doOutput to keepAcceptance check
1. Fix the populationState the systems, date range, window rule and case definitionOne-page frame definitionAnother engineer can rebuild the same case list
2. Reconcile to sourceCompare case counts by month and status with a system reportReconciliation table with differences explainedUnexplained gap under an agreed tolerance
3. Write branch rulesDefine each branch by its decisive event or state sequenceBranch rule list with examplesEvery case lands in exactly one branch
4. Count the frameAssign all cases and count each branchBranch count tableCounts sum to the reconciled population
5. Set floorsPick a minimum per rare branch; take all cases where a branch is smallerFloor and take-all listFloor is justified by the review task, not by habit
6. Allocate the restSpread the remaining budget over common branches by size or variabilityAllocation tableAllocations sum to the total sample size
7. Draw within strataRandom draw inside each branch with a recorded seedSampled case IDs and seedRe-running with the seed returns the same cases
8. Compute weightsWeight each case by stratum population over stratum sampleWeight column on every sampled caseWeighted counts reproduce the frame counts
9. Document limitsNote truncated, low-confidence and take-all strataLimitations noteEach limit names the branches it affects

Writing exception-path rules a reviewer can apply

Define a branch by the event or state that makes it different, not by its full activity sequence. Full variants multiply quickly in real logs, because retries, reorderings and optional steps create a new variant for small differences, and a stratum per variant leaves most strata with one case. A decisive-event rule groups cases a reviewer would treat alike.

At a glance

Writing exception-path rules a reviewer can apply

Write each rule so it can be tested against the log without judgment calls, and keep a precedence order for cases that match two rules. A case that was rejected, resubmitted and then overridden needs one home, usually the rarest or most consequential branch it touched.

Keep the rules close to how the business names its own exceptions. If finance calls something a controller override, use that name and the system event that records it; the sample will be easier to explain and the rule easier to audit.

  • Rejection and resubmission: a reject status followed by a later submit on the same case.
  • Override: an approval or posting by a role outside the normal approval path, recorded as a distinct event or user role.
  • Rework loop: the same activity repeated after a later activity has started, beyond a stated repeat count.
  • Escalation: a hand-off to a higher tier, a supervisor or an external party.
  • Cancellation after commitment: a cancel or reversal after an approval, confirmation or shipment event.
  • Timeout or breach: a case whose duration passes the service level or policy limit the business uses.
  • Straight-through: none of the above, with the expected start and end events present.

Allocating the sample and keeping it honest with weights

Set floors from the review task. If the person evaluating the sample needs to see enough cases of each branch to judge consistency, a floor of a few dozen per branch is a common starting point; if they only need to confirm a branch exists and is handled, a smaller floor works. Where a branch has fewer cases than the floor, take every case and say so.

Then allocate the remaining budget across common branches. Proportional allocation is the safe default. Giving more cases to branches whose cases vary more, such as long or multi-party cases, buys more information per case but should be stated in the plan.

Oversampling only stays honest if the weights travel with the sample. Survey statisticians handle the same issue routinely: CDC's NHANES tutorials explain that oversampling raises the precision of estimates for subgroups and that sample weights are what allow those subgroup estimates to be combined into national figures. A workflow sample is no different. Report branch-level findings unweighted, and report any population figure, such as the share of cases that needed rework, with weights.

Clock drift, ID mismatches and missing transitions: when a case changes branch

Each of these can move a case from one branch to another, and the rare branches are the most exposed because a handful of misassigned cases is a large share of a small stratum. Test for them on the sampled cases before anyone reviews the content.

Clock drift reorders events. A rework loop can appear when a status update from one system lands a few minutes before the event it responds to, and a real loop can disappear the other way. Compare timestamps on paired events, such as a request and its response, and flag cases where the order contradicts the business logic.

Identifier mismatches split or merge cases. Watch for cases with no start event, two start events or a terminal event followed by more activity. Unrecorded transitions are the hardest: an approval given by phone and entered later, or a status changed in a spreadsheet, leaves a gap that looks like a straight-through case. Score each sampled case high, medium or low on reconstruction confidence and keep low-confidence cases in the sample, labeled, rather than silently replacing them.

Worked example (illustrative): an invoice exception workflow

The figures here are invented to show the arithmetic. A finance team has 40,000 reconciled invoice cases for one year and a review budget of 400 cases. Six branch rules assign every case. A simple random sample of 400 would be expected to contain about one controller override and about one cancellation after approval, too few to say anything about how either is handled.

The plan sets a floor of 40 for each of the four smallest branches, gives 60 to price variances and leaves 180 for straight-through cases. Weights are population over sample: each sampled straight-through case stands for about 193 cases, and each override for 3. Weighted counts reproduce the 40,000 total, so a population share computed from the sample still matches the frame.

Branch-level review then shows something a random sample could not: whether overrides cite a reason, whether resubmitted invoices changed the disputed field, and whether cancellations after approval were reversed in the ledger. If 12 of the 40 overrides carry no recorded reason, that is a finding about the branch, reported as 12 of 40 sampled, not scaled up to a population claim without weights.

Worked example (illustrative): an invoice exception workflow
BranchCases in frameExpected in a random 400Plan allocationWeight per sampled case
Straight-through match34,800348180193.3
Price variance resolved by buyer3,200326053.3
Quantity variance on partial receipt1,400144035
Rejected then resubmitted3603.6409
Controller override1201.2403
Canceled after approval1201.2403

Where the plan stops working, and preparing an exception-heavy sample to share

The plan cannot rescue branches that the logs never record. If an exception lives only in email or a free-text note, stratify on a reviewed text label instead and state that the branch count depends on that labeling. Narrow the scope when branch rules keep changing after people have seen the sample, because rules written from the sample rather than the frame bias it. Bring in a process mining engineer and the workflow owner when reconciliation gaps stay unexplained or when object relationships are many-to-many across several systems.

Rare branches also carry more re-identification risk. A stratum of a few dozen overrides may point to a handful of named approvers, so code people and counterparties and check small cells before any sample leaves the company. Draw whole cases, never individual events: work on sampling object-centric logs points out that randomly sampling events or objects trims object lifecycles and removes the relationships between them, which would turn a rare branch into a fragment.

A branch-stratified sample and the plan that produced it are exactly what a licensing review wants to see, and when a company chooses to license such a dataset, SourceX handles the sourcing, rights review, contracting, preparation, delivery and payment around it. Bulky workflow archives need not be copied to a new host, since they can remain in the company's storage or travel on encrypted drives, and eligibility is checked first through a short assessment that asks for no files.

Frequently asked questions

What is branch stratified sampling for workflow data?

It is a sampling plan that groups reconstructed cases by the branch they took, such as straight-through, rejected or overridden, and draws from each group separately. Rare branches get a minimum number of cases, and every case carries a weight so the sample can be reweighted to the real mix.

How many cases should a rare branch get in a sample?

Set the floor from the review task: enough cases for a reviewer to judge whether the branch is handled consistently, often a few dozen. If the branch has fewer cases than the floor, include all of them and record it as a take-all stratum.

Is a workflow variant the same as a branch?

Not usually. A variant is a distinct full sequence of activities, and real logs produce many near-duplicate variants. A branch is defined by a decisive event or state, so it groups cases a reviewer would treat alike and keeps strata large enough to sample.

Does oversampling rare branches bias the sample?

Only if the weights are dropped. Branch-level findings are reported within each branch, and any population figure is computed with weights equal to stratum population divided by stratum sample, which reproduces the true mix.

Should low-confidence reconstructed cases be removed from the sample?

No. Keep them, label their confidence and the reason, and report results with and without them. Replacing them quietly hides exactly the cases where clock drift, identifier mismatches or unrecorded transitions may have changed the branch.

Sources

  • The pm4py process mining library's sample_cases function randomly samples a given number of cases from an event log. Source
  • pm4py's filtering module documents a coverage-based variant filter (with a 1,000-case example) and time-range filter modes that keep events, fully contained traces or intersecting traces. Source
  • scikit-learn documents that StratifiedShuffleSplit preserves the percentage of samples for each class and raises an error when a class has only one member. Source
  • CDC's NHANES weighting tutorial explains that oversampling increases precision for subgroups and that sample weights allow subgroup estimates to be combined into national estimates. Source
  • A systematic literature review of object-centric process mining describes deficiency, convergence and divergence as the problems caused by flattening a log to one case notion. Source
  • Berti's paper on filtering and sampling object-centric event logs explains that randomly sampling events or objects trims object lifecycles and removes relationships between them. Source
  • The OCEL 2.0 specification defines an object-centric event log format that records object relationships and qualifies relationships to other objects or to specific events. Source

See if your company qualifies

A short company assessment. No data uploads are needed.

See if your company qualifies