Fable findings in data

This commit is contained in:
Andras Schmelczer 2026-06-11 07:49:23 +01:00
parent b98bc6d611
commit 6a33b03fdf
20 changed files with 1502 additions and 274 deletions

View file

@ -65,7 +65,7 @@
"sys.path.insert(0, str(ROOT))\n",
"DATA = ROOT / \"property-data\"\n",
"\n",
"from pipeline.transform import school_catchments as sc\n",
"from pipeline.transform import school_catchments as sc # noqa: E402\n",
"\n",
"print(\"Calibrated constants (see the calibration section for how these were chosen):\")\n",
"print(f\" DEMAND_SCALE = {sc.DEMAND_SCALE}\")\n",
@ -292,10 +292,13 @@
" z = np.stack([-eff_good / tau, -d_other / tau])\n",
" share_good = np.exp(z[0] - z.max(0)) / np.exp(z - z.max(0)).sum(0)\n",
" ax.plot(xs, share_good, ls, label=f\"tau = {tau} km\")\n",
"ax.axvline(0, color=\"tab:green\", lw=1); ax.text(0, 1.04, \"Good school\", ha=\"center\", color=\"tab:green\")\n",
"ax.axvline(1, color=\"tab:gray\", lw=1); ax.text(1, 1.04, \"unrated school\", ha=\"center\", color=\"tab:gray\")\n",
"ax.axvline(0, color=\"tab:green\", lw=1)\n",
"ax.text(0, 1.04, \"Good school\", ha=\"center\", color=\"tab:green\")\n",
"ax.axvline(1, color=\"tab:gray\", lw=1)\n",
"ax.text(1, 1.04, \"unrated school\", ha=\"center\", color=\"tab:gray\")\n",
"ax.set(xlabel=\"family position (km)\", ylabel=\"share applying to the Good school\", ylim=(0, 1.12))\n",
"ax.legend(loc=\"lower left\"); fig.tight_layout()\n"
"ax.legend(loc=\"lower left\")\n",
"fig.tight_layout()\n"
]
},
{
@ -383,7 +386,8 @@
"ax2.bar(x + 0.18, sme, 0.36, label=\"logit (tau=0.3)\")\n",
"ax2.set(xticks=x, xticklabels=[\"A\", \"B\", \"C\"], ylabel=\"final cutoff (km)\",\n",
" title=\"smearing widens the popular school's cutoff\")\n",
"ax2.legend(); fig.tight_layout()\n",
"ax2.legend()\n",
"fig.tight_layout()\n",
"print(\"deterministic cutoffs:\", np.round(det, 2), \" logit cutoffs:\", np.round(sme, 2))\n"
]
},
@ -586,7 +590,8 @@
"ax.plot([], [], color=\"tab:purple\", label=\"Outstanding primary catchment\")\n",
"ax.set(xlim=(-half, half), ylim=(-half, half), xlabel=\"km east of Cambridge centre\",\n",
" ylabel=\"km north\", title=\"Modelled primary catchments around Cambridge\")\n",
"ax.set_aspect(\"equal\"); ax.legend(loc=\"upper left\", fontsize=8)\n",
"ax.set_aspect(\"equal\")\n",
"ax.legend(loc=\"upper left\", fontsize=8)\n",
"fig.tight_layout()\n"
]
},
@ -686,7 +691,9 @@
" s=14, alpha=0.5, color=\"tab:orange\", marker=\"^\", label=f\"faith (n={len(sub)})\")\n",
"ax.set(xscale=\"log\", yscale=\"log\", xlim=lim, ylim=lim,\n",
" xlabel=\"published last distance offered (km)\", ylabel=\"modelled cutoff radius (km)\")\n",
"ax.set_aspect(\"equal\"); ax.legend(fontsize=8); fig.tight_layout()\n",
"ax.set_aspect(\"equal\")\n",
"ax.legend(fontsize=8)\n",
"fig.tight_layout()\n",
"\n",
"for phase in (\"primary\", \"secondary\"):\n",
" sub = binding.filter((pl.col(\"phase\") == phase) & ~pl.col(\"faith_school\"))\n",