Suppose you want the typical architecture drift for room outputs whose watermark notes begin with yes. You have a column of recorded text, a numeric score and two alignment flags. Before reaching for the median, settle two questions. Which opening words count as yes? Which rows measure drift on comparable terms? The room records in the StagingBench results let you see what each choice does to the calculation.

Use a word boundary

Read the watermark field as text and take its first word after stripping surrounding whitespace and folding case. Matching a word handles the colon in Yes:. Splitting on whitespace alone would leave that colon attached. Match yes and no as whole words so that a longer word starting with the same letters cannot slip into either class. Send everything else, including an empty string, to other. This rule groups observations by how the writer opened the note. Keep the original text available if you need to interpret a group later.

Save the following as summary.py and run python3 -I summary.py wm_drift.csv, passing the path to the CSV as the argument. The CSV is a flat export of the room records with the columns tool, room, watermark, architecture_drift, drift_aligned and alignment_ok. The script reads the recorded text directly and prints each class in the same order every time.

import csv import math import re import sys from statistics import median groups = {key: [] for key in ("yes", "no", "other")} with open(sys.argv[1], newline="", encoding="utf-8") as source: for row in csv.DictReader(source): first = re.match(r"\w+", row["watermark"].strip().casefold()) word = first.group() if first else "" key = word if word in ("yes", "no") else "other" flags = (row["alignment_ok"], row["drift_aligned"]) if any(flag.strip().casefold() == "false" for flag in flags): continue try: score = float(row["architecture_drift"]) except ValueError: continue if math.isfinite(score): groups[key].append(score) print("class n median min max") for key, scores in groups.items(): if scores: print(key, len(scores), f"{median(scores):.1f}", f"{min(scores):.1f}", f"{max(scores):.1f}") else: print(key, 0, "NA NA NA") 

The run produced this output.

class n median min max yes 45 22.9 7.8 46.3 no 39 21.1 6.1 52.8 other 9 9.7 6.4 27.8 

Say exactly which flags you kept

Alignment puts the staged image into the original photograph's frame before structural edges are compared. When alignment fails, the fallback compares the resized output with the original. A shift in framing can then contribute to the measured difference. Pooling those fallback values with the other scores would change what the median describes. Either flag carrying an explicit false is enough to exclude a row. The methodology explains the fallback.

There is a quieter choice in that condition. Eight records have blank alignment flags. They pass the stated rule because neither flag explicitly says false. Requiring both flags to say true would omit those eight as well. Describe the inclusion rule when you publish the result so someone rerunning the comparison can recover your counts. Calling every retained row a confirmed alignment would overstate what the flags establish.

Read the count before the median

Across all notes, the yes, no and other groups contain 60, 49 and 10 records. After filtering, the counts sum to 93. The n column gives the denominator for each summary and provides a quick check that the filtering step actually ran. It also puts 9.7 in perspective. That median is the middle of nine qualifying scores from one tool whose notes open with a description of the provider's policy. An unusual opening word can group together outputs with a great deal else in common.

Finally, subtract 21.1 from 22.9. The resulting 1.8 point gap falls below the methodology's noise level of about 3 points. Look alongside it at the observed spread. The no range extends past the yes range at both ends. The groups also draw on different tools and different mixes of room records, so subtracting the medians cannot isolate a contribution from the watermark. To investigate that question, score the same staged image from the same tool with and without the mark, then calculate the difference within each room. That calculation keeps the room and its contents fixed while the feature under study changes.