SPB Git

spb/wp2_uqo Public

UQO Working Paper No. 2 — Decoding Real Estate Descriptions: text-based hedonic analysis of housing listings.

TeX 73.8% Python 26%
8.1 KB

# CHANGES — restructuring of immo-wp2-spb-20260519 → wp2_uqo

Original project: ~/Desktop/UQO/UQO_WP/immo-wp2-spb-20260519 (untouched, serves as backup). New repository: ~/Desktop/wp2_uqo. Date: 2026-08-05.

# 1. What was moved / renamed

Original New location
louka.db data/raw/louka.db
embeddings_maisons.npy, sim_matrix_maisons.npy data/processed/ (pipeline cache)
hedonic_maison_results.csv (+ earlier-approach CSVs/NPYs) data/processed/legacy/ (originals kept for comparison)
hedonic_maison.py (818 lines, monolithic) split into src/ modules + scripts/01–04
paper_figures_v2.py scripts/05_figures.py (ports all 11 figures)
wp2/main.tex + wp2/sections/ + wp2/tables/ paper/ (preamble extracted to paper/preamble.tex)
hedonic_semantic.py, hedonic_cosine_references.py, paper_figures.py, root LaTeX tree, paper.tex not migrated (superseded; documented in AUDIT.md)

# 2. Code refactoring

  • All hardcoded paths to the defunct ~/Desktop/d/ replaced by repository-relative paths in src/config.py (overridable via WP2_DB_PATH).
  • The DB-extraction block that was copy-pasted across 5 scripts now lives once in src/data.py; the 20 reference descriptions (pasted 3×, in two languages) live once in src/references.py (slugs for data columns, English labels for display).
  • Models A–E defined once in src/models.py; robustness checks ported faithfully (same estimators, same seeds: bootstrap np.random.seed(42), CV random_state=42).
  • New numbered pipeline: 01_prepare_data02_similarities03_models04_robustness05_figures06_tables. Everything runs end-to-end from data/raw/louka.db; embeddings are cached and --force re-encodes.
  • New scripts/06_tables.py generates the paper's numeric tables directly from the pipeline results — this closes the transcription gap that produced the wrong numbers documented in §4 below.
  • requirements.txt pins the exact package versions used for verification.

# 3. Verification (regenerated vs. original artifacts)

  • Sample: 17,087 houses — identical (all 30 columns of hedonic_maison_results.csv equal to the original; similarity matrix bit-identical).
  • Models A–E: R², adj. R², AIC, BIC, k — identical to the paper's Table 4 (e.g. R² 0.4525 / 0.4647 / 0.4962 / 0.5122 / 0.5118; joint F = 99.53).
  • Model D coefficients: identical to the paper's Table 5 (all 27 coefficients, SEs, t-stats, impacts).
  • Figures: regenerated fig1, fig4–fig11 match the shipped ones (same content, PDF sizes within ±2 bytes). fig2 and fig3, referenced by the paper but missing from the original repo (the compiled PDF showed "Figure indisponible" boxes), are regenerated and now included.
  • robustness_results.csv, lost in the original, is regenerated (seeded, reproducible).

The original LaTeX contained statistics that do not match the actual pipeline outputs (the project's own figures/table1/table2 CSVs confirm the pipeline values). They appear to have been transcribed from memory/drafted text rather than from the analysis output. All were replaced by the reproducible values; the paper's tables are now machine-generated (scripts/06_tables.py).

Claim Old (paper) New (verified)
Price mean $764,508 $807,259 (median $589,900 unchanged)
Description length mean 683, sd 367, max 5,399 mean 510, sd 151, max 703 (field truncated ~700 chars — now noted in the text)
Parking mean 2.3 5.5 (counts all spots incl. driveway — now explained)
log-price sd 0.68 0.70
Similarity stats & correlations (Table 3) e.g. Luxury corr −0.178 regenerated (e.g. Luxury −0.234; all in [−0.29, −0.17])
Breusch–Pagan LM = 2,847.3 LM = 768.0 (same conclusion)
VIF "none > 10, mean ≈ 4.2" mean 17.2, 16/20 > 10 — subsection rewritten honestly (block-level inference unaffected; O'Brien 2007 argument)
Inter-reference correlations "0.4–0.8", "Motivated Seller lowest" 0.66–0.97, mean 0.84; top pair Entry-Level/Motivated Seller r = 0.97
Winsorized model 342 obs dropped, adj R² 0.498, shifts Luxury −0.012 / Motivated +0.008 341 obs, adj R² 0.486, largest shifts Entry-Level −0.024 / Motivated Seller +0.023 (no sign reversals, all 16 stay significant — unchanged conclusions)
Bootstrap "SE within 5% of HC3" within 9% (15/20 within 5%)
Lasso / Elastic Net "Lasso keeps 15/20, ENet 17/20, high concordance with OLS" both keep 4/20 — subsection rewritten: sparse block-representative selection under strong collinearity, complementary rather than concordant
Quantile table e.g. Luxury 0.098/0.125/0.176; "Modern & Land increasing" regenerated (Luxury 0.093/0.130/0.160 increasing ✓; Modern high at both tails; Land & Nature stable)
PCA comparison "PCA yields R² 0.496 < 0.512 → reference approach outperforms" PCA(20) actually fits better: ΔR² +0.070 vs +0.044 (49.5 % variance ✓). Reframed as an explicit interpretability-vs-fit trade-off (Table 8 + Discussion §PCA rewritten)

Qualitative conclusions that survive unchanged: heteroskedasticity → HC3; no sign reversals under trimming; bootstrap ≈ HC3; Luxury premium increasing in quantiles; discounts attenuating; joint semantic block highly significant. Claims that had to change substance: VIF/multicollinearity (now acknowledged as substantial), Lasso concordance (now honest about sparse selection), and PCA fit comparison (now favors PCA on fit, reference approach on interpretability). These are flagged because they alter the robustness narrative, not the headline results.

# 5. Paper rewrite (Phase 3)

  • paper/main.tex slimmed (metadata + inputs); packages and macros extracted to paper/preamble.tex; figures pulled from ../figures/ via \graphicspath; the main_web.tex variant with the silent figure-fallback hack was dropped.
  • All [TODO] blocks removed (robustness §7.7–7.9, methodology, summary table) and converted into completed analyses (PCA comparison), honest limitations (Discussion), or future-research items (Conclusion).
  • New appendix with real content: A. verbatim French reference descriptions (replication) and B. Model E coefficient table — both machine-generated.
  • Editorial pass on Data/Results/Robustness/Discussion: corrected figure-3 caption (boxplots, not KDE), documented the description-truncation and parking-field quirks, tightened the collinearity narrative, consistent notation preserved.
  • Fig 10 y-labels now use readable names instead of raw variable names.
  • Title page: "First draft: May 2025" corrected to May 2026 (the data were scraped January 2026); version bumped to 1.1.
  • Abstract: "robust to bootstrap inference, winsorization, and Lasso selection" → "robust to bootstrap inference and outlier trimming" (accurate).
  • Compiles clean: latexmk -pdf main.tex47 pages, 0 errors, 0 undefined references/citations (24 minor overfull hboxes). Bibliography complete (59/59 cited keys resolve).

# 6. Items for your review

  1. §4 corrections — especially VIF, Lasso, and PCA, which change the robustness narrative (the old text claimed low collinearity and high selection concordance; the data say otherwise). Verify you are comfortable with the new framing before circulating.
  2. data/raw/louka.db contains a users table with plaintext credentials (application leftover, unused by the analysis). Consider stripping it: sqlite3 data/raw/louka.db "DROP TABLE users; VACUUM;".
  3. The description-length truncation (~700 chars) is now disclosed in the paper; if a non-truncated export exists, re-running the pipeline on it would be easy.
  4. The quantile-regression standard errors use the statsmodels kernel-based estimator (the old table note claimed bootstrap SEs, which was never the case).
  5. Original folder immo-wp2-spb-20260519 was left untouched; delete or archive it once you're satisfied with wp2_uqo.