SPB Git forge

spb/wp4_uqo

Public
3commits 1branches 1releases
5.4 MBsize
maindefault branch
1 h agolast push
Python 64.6% TeX 23.3% HTML 11.6% Makefile 0.5%
1.2 KB · 18 lines python
Raw Blame History
1#!/usr/bin/env python32"""Write results/tables/rev_vif.tex from the VIFs stored in rev_key_numbers.json (companion of 10_revision_reanalysis.py)."""3import json4from pathlib import Path5ROOT = Path(__file__).resolve().parent.parent6k = json.loads((ROOT / "results/tables/rev_key_numbers.json").read_text())7LAB = {"ln_bedrooms": "ln(bedrooms)", "ln_bathrooms": "ln(1 + bathrooms)", "ln_guests": "ln(guests)", "shared_bath": "Shared bathroom",8       "studio": "Studio", "ln_amenities": "ln(1 + amenities)", "pets_allowed": "Pets allowed", "ln_images": "ln(1 + photos)",9       "is_superhost": "Superhost", "is_guest_favorite": "Guest Favourite", "ln_reviews": "ln(1 + reviews)", "rated": "Rated (star shown)",10       "rating_c": "Rating $-$ 4.8 (rated only)", "ln_dist": "ln(1 + km to centre)", "ln_density_1km": "ln(1 + listings within 1 km)",11       "Hotel/B&B/hostel": "Hotel/B\\&B/hostel"}12rows = ["\\begin{tabular}{lr}", "\\toprule", "Regressor & VIF \\\\", "\\midrule"]13for v, x in k["vif"].items():14    rows.append(f"{LAB.get(v, v)} & {x:.2f} \\\\")15rows += ["\\bottomrule", "\\end{tabular}"]16(ROOT / "results/tables/rev_vif.tex").write_text("\n".join(rows))17print("rev_vif.tex written; max VIF", round(k["vif_max"], 2), k["vif_argmax"])18