A median can tell you where a set of architecture drift scores is centered. To see how much the scores vary across rooms staged by the same tool, calculate the interquartile range alongside it. Lower drift means the staged image retained more of the original walls, windows, and doors. The StagingBench observations here cover 129 room results across 13 tools. Twelve tools have ten rooms each, and T12 has nine.
The script uses three standard library modules. csv.DictReader reads the embedded rows by column name. A collections.defaultdict collects the drift values by tool, with one observation for each room in that group. The statistics module calculates the median and the quartiles. Pass n=4 and method="inclusive" to quantiles, then subtract the first quartile from the third to get the width of the middle half of the distribution.
Every input score has one decimal place, so removing the decimal point stores each value as an integer number of tenths. The comparisons then use 100 for 10 and 300 for 30. The code counts values strictly below the first cutoff and values equal to or above the second. It adds one to the overall count of tools with both whenever the two counts for a group are positive. The formatter converts the summary values back to drift units and rounds halfway values up to two decimal places.
import csv
import statistics
from collections import defaultdict
DATA = """tool,room,architecture_drift
T01,01,16.2
T01,02,32.9
T01,03,9.2
T01,04,40.1
T01,05,13.7
T01,06,43.4
T01,07,41.0
T01,08,11.6
T01,09,13.1
T01,10,22.7
T02,01,11.0
T02,02,24.1
T02,03,21.7
T02,04,56.5
T02,05,21.4
T02,06,26.2
T02,07,35.1
T02,08,17.4
T02,09,9.2
T02,10,28.0
T03,01,28.2
T03,02,30.6
T03,03,29.7
T03,04,29.0
T03,05,15.5
T03,06,21.1
T03,07,18.0
T03,08,12.6
T03,09,14.9
T03,10,20.2
T04,01,27.1
T04,02,26.6
T04,03,33.5
T04,04,28.8
T04,05,22.5
T04,06,21.3
T04,07,24.4
T04,08,23.5
T04,09,26.9
T04,10,26.6
T05,01,29.4
T05,02,6.1
T05,03,23.6
T05,04,61.5
T05,05,36.2
T05,06,57.3
T05,07,30.4
T05,08,22.0
T05,09,11.4
T05,10,19.9
T06,01,18.1
T06,02,23.3
T06,03,21.0
T06,04,33.3
T06,05,14.8
T06,06,22.5
T06,07,35.2
T06,08,27.4
T06,09,10.2
T06,10,21.2
T07,01,25.4
T07,02,33.6
T07,03,22.9
T07,04,50.4
T07,05,38.0
T07,06,34.9
T07,07,46.3
T07,08,38.7
T07,09,20.4
T07,10,28.2
T08,01,11.4
T08,02,31.3
T08,03,26.3
T08,04,15.1
T08,05,34.9
T08,06,16.6
T08,07,23.5
T08,08,9.7
T08,09,5.7
T08,10,24.5
T09,01,13.3
T09,02,11.6
T09,03,26.4
T09,04,10.4
T09,05,19.8
T09,06,26.0
T09,07,18.9
T09,08,7.8
T09,09,23.3
T09,10,21.0
T10,01,10.6
T10,02,27.8
T10,03,7.5
T10,04,6.4
T10,05,7.8
T10,06,13.7
T10,07,9.7
T10,08,8.9
T10,09,3.1
T10,10,17.0
T11,01,52.8
T11,02,27.1
T11,03,61.3
T11,04,54.5
T11,05,7.2
T11,06,9.7
T11,07,9.2
T11,08,35.5
T11,09,7.7
T11,10,26.6
T12,01,18.9
T12,02,25.4
T12,03,19.1
T12,04,15.2
T12,05,8.0
T12,06,16.3
T12,07,42.1
T12,09,11.8
T12,10,15.7
T13,01,12.7
T13,02,16.9
T13,03,4.0
T13,04,52.8
T13,05,18.8
T13,06,12.6
T13,07,7.3
T13,08,41.5
T13,09,2.4
T13,10,57.4
"""
def format_drift(tenths):
cents = int(tenths * 10 + 0.5)
return f"{cents / 100:.2f}"
groups = defaultdict(list)
for row in csv.DictReader(DATA.splitlines()):
drift = int(row["architecture_drift"].replace(".", ""))
groups[row["tool"]].append(drift)
total_rooms = sum(map(len, groups.values()))
print(f"{total_rooms} observations across {len(groups)} tools")
print("tool n median IQR min max below_10 at_least_30")
both = 0
for tool, values in sorted(groups.items()):
q1, _, q3 = statistics.quantiles(values, n=4, method="inclusive")
below = sum(value < 100 for value in values)
above = sum(value >= 300 for value in values)
both += int(below > 0 and above > 0)
print(
tool,
len(values),
format_drift(statistics.median(values)),
format_drift(q3 - q1),
format_drift(min(values)),
format_drift(max(values)),
below,
above,
)
print(f"Tools with both: {both} of {len(groups)}")
Running the script produces the output below. The first line counts all observations. Each subsequent record starts with the tool ID and its individual sample size, followed by the median, IQR, minimum, maximum, and cutoff counts. The final line counts qualifying tools once each, even when several of their rooms meet either cutoff.
129 observations across 13 tools
tool n median IQR min max below_10 at_least_30
T01 10 19.45 25.05 9.20 43.40 1 4
T02 10 22.90 9.15 9.20 56.50 1 2
T03 10 20.65 12.68 12.60 30.60 0 1
T04 10 26.60 3.33 21.30 33.50 0 1
T05 10 26.50 14.33 6.10 61.50 1 4
T06 10 21.85 7.55 10.20 35.20 0 2
T07 10 34.25 12.43 20.40 50.40 0 6
T08 10 20.05 13.53 5.70 34.90 2 2
T09 10 19.35 10.70 7.80 26.40 1 0
T10 10 9.30 5.35 3.10 27.80 6 0
T11 10 26.85 39.15 7.20 61.30 4 4
T12 9 16.30 3.90 8.00 42.10 1 1
T13 10 14.80 27.20 2.40 57.40 3 3
Tools with both: 7 of 13
Compare T04 with T11. The medians, 26.60 and 26.85, place their centers close together. Their IQRs, 3.33 and 39.15, show different amounts of variation through the middle of the observed scores. The cutoff columns add another view of the same groups. T10 recorded six rooms below 10, T07 recorded six at or above 30, and seven tools recorded at least one room on each side. The extrema give the actual endpoints, which is helpful when a group has a narrow IQR and a distant maximum, as T12 does.
The quartiles are rough with nine or ten scores in a group. Interpolation places the quartile marks between observations when needed, and replacing even one room near a mark can shift the result. The summary also pools 29 raw observations from failed alignments with 91 observations marked as aligned and nine with blank alignment flags. The three embedded columns preserve the scores for that pooled calculation. Read the median and spread as separate descriptions of architecture drift across these rooms. Overall tool quality is outside the scope of the calculation.
Top comments (0)