DEV Community

StagingBench Team
StagingBench Team

Posted on AI-assisted

Count architecture drift in buckets with Python

StagingBench uses architecture drift to measure how much a virtual staging run changes the room itself. Lower scores indicate that walls, windows and fixtures stayed closer to the input. A mean compresses a tool's runs into one number. Bucket counts show where those runs landed, including how often scores fell at either end of the distribution.

Choose explicit boundaries

The five buckets are under 10, 10 to under 20, 20 to under 30, 30 to under 40, and 40 or more. Each score goes into one bucket. A score exactly on a cutoff enters the bucket that begins there. The code counts how many cutoffs a score meets or exceeds and uses that number as its bucket index. That gives the lowest bucket index zero and the highest index four.

The script embeds the 129 scored runs from the 1 December 2026 snapshot. Each tuple contains a tool ID, a room ID and a drift score. Room IDs are strings so that 01 keeps its leading zero. The script prints the tool IDs in order, then the combined bucket counts and the median of the individual drift scores.

from collections import defaultdict
from statistics import median

runs = [
    ("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),
]

counts = defaultdict(lambda: [0] * 5)
totals = [0] * 5
cutoffs = (10, 20, 30, 40)

for tool, room, drift in runs:
    bucket = sum(drift >= cutoff for cutoff in cutoffs)
    counts[tool][bucket] += 1
    totals[bucket] += 1

for tool in sorted(counts):
    a, b, c, d, e = counts[tool]
    print(f"{tool}: {a} {b} {c} {d} {e}")

a, b, c, d, e = totals
print(f"Total: {a} {b} {c} {d} {e}")
print(f"Median: {median(drift for _, _, drift in runs):.2f}")
Enter fullscreen mode Exit fullscreen mode
T01: 1 4 1 1 3
T02: 1 2 5 1 1
T03: 0 4 5 1 0
T04: 0 0 9 1 0
T05: 1 2 3 2 2
T06: 0 3 5 2 0
T07: 0 0 4 4 2
T08: 2 3 3 2 0
T09: 1 5 4 0 0
T10: 6 3 1 0 0
T11: 4 0 2 1 3
T12: 1 6 1 0 1
T13: 3 4 0 0 3
Total: 20 36 43 15 15
Median: 21.70
Enter fullscreen mode Exit fullscreen mode

The script prints the counts in order from the lowest drift bucket to the highest.

Read the counts alongside the median

The median of 21.70 gives the middle observed score across the entire snapshot. The buckets show how runs are distributed around it. There were 43 runs from 20 to under 30, 20 runs under 10, and 15 runs at 40 or more. The low and high ends stay visible even when the middle of the distribution fits in a single bucket.

Individual rows reveal different patterns. T04 had nine runs from 20 to under 30 and one from 30 to under 40. T11 had four runs under 10 and three at 40 or more. Those counts describe how concentrated or spread out each set of scores was. A mean on its own cannot tell you how often either range occurred.

Each count has a denominator. For most tools the five counts add up to ten. For T12 they add up to nine because room 08 has no score after the app refused the run. The totals and median use the runs that produced a score, with each recorded run contributing once.

The cutoffs make the output easy to scan, but adjacent buckets can contain nearly identical values. Scores just below and just above 20 land in different columns even when their gap is within measurement noise. Use the buckets to see how often scores land in each range, then return to the room scores when the size of a particular difference matters.

Top comments (0)