"""Claim 5 figure: the floor effect that makes the intervention comparison uninformative.""" import json, matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt import numpy as np d = json.load(open("/tmp/res/claim5/claim5.json")) s = d["summary"] arms = ["neglectful", "team_competition", "teacher_reminder", "pre_education"] labels = ["Control\n(Neglectful)", "Team\nCompetition", "Teacher\nReminder", "Pre-\nEducation"] fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11.5, 4.6)) # LEFT: the floor effect -- cooperative vastly outnumbers malicious in every arm. coop = [s[a]["cooperative_mean"] for a in arms] mal = [s[a]["malicious_mean"] for a in arms] x = np.arange(len(arms)); w = 0.38 ax1.bar(x - w/2, coop, w, label="cooperative", color="#55A868") ax1.bar(x + w/2, mal, w, label="malicious competition", color="#C44E52") ax1.set_xticks(x); ax1.set_xticklabels(labels) ax1.set_ylabel("Mean behaviours per episode") ax1.set_title("The floor effect: almost no malicious competition occurred") ax1.legend(fontsize=8); ax1.grid(axis="y", alpha=0.3) for i, (c, m) in enumerate(zip(coop, mal)): ax1.text(i - w/2, c + 0.3, f"{c:.1f}", ha="center", fontsize=9) ax1.text(i + w/2, m + 0.3, f"{m:.2f}", ha="center", fontsize=9, color="#C44E52") ax1.text(0.5, 0.62, "534 cooperative vs 11 malicious\nacross all 32 episodes\n25/32 episodes had ZERO", transform=ax1.transAxes, fontsize=9, ha="left", va="top", bbox=dict(boxstyle="round,pad=0.5", fc="#FFF7E0", ec="#C9A24A")) # RIGHT: boxplot of malicious competition -- the quantity Claim 5 is about. data = [[r["malicious_competition"] for r in d["records"] if r["arm"] == a and r["valid"]] for a in arms] bp = ax2.boxplot(data, tick_labels=labels, whis=(0, 100), showmeans=True, meanline=True, meanprops={"color": "red", "linestyle": "--", "linewidth": 1.6}, medianprops={"color": "#333"}, patch_artist=True) for patch, a in zip(bp["boxes"], arms): patch.set_facecolor("#F2C4C4" if a == "neglectful" else "#CFD9EA") patch.set_edgecolor("#555") ax2.set_ylabel("Malicious competition per episode") ax2.set_title("Paper predicts control = WIDEST spread.\nObserved: control = narrowest (range 1 vs 2)") ax2.grid(axis="y", alpha=0.3) ax2.set_ylim(-0.15, 2.4) fig.suptitle("Claim 5 NOT reproduced: the control never produced the extreme competition\n" "that the interventions are supposed to mitigate", fontsize=11) fig.tight_layout() fig.savefig("outputs/figures/claim5_floor_effect.png", dpi=150) print("wrote outputs/figures/claim5_floor_effect.png") print("coop means:", coop, "| malicious means:", mal) print("stdevs:", [s[a]["malicious_stdev"] for a in arms]) print("ranges:", [s[a]["malicious_range"] for a in arms])