feat(tradein): same-building anchor estimator (#651/#652 v2) behind flag #677

Merged
bot-reviewer merged 1 commit from feat/tradein-same-building-anchor into main 2026-05-29 21:01:22 +00:00
Collaborator

Summary

Fixes the core accuracy bug: radius-median ppm2 systematically underestimated premium ~2.5x and comfort ~15-25% by diluting the building/complex premium. Replaces the radius median with a same-building anchor (industry-standard: Fannie Mae same-project-comps-preferred, similarity weighting, segment purity, premium guardrail, FSD range).

  • Tiered comps (first tier >=2): A same building (normalized street+house, relaxed rooms, no area filter, NOT grouped by house_id_fk) -> C <=500m same-segment -> D existing radius fallback.
  • Anchor = similarity-weighted mean ppm2 + guarded premium p70 uplift + ppm2-banded asking->sold haircut (4-7%) + hard guardrail (>= min same-building ppm2 x0.95) + tightened FSD range.
  • Address normalizer: e->e, alias Tkacheva->Tkachey, base-house-number across corpus letters.
  • Anchor PRIMARY when Tier A/C fires; IMV blend only in Tier D (no double-apply); expected_sold consistent; avito_imv + dkp_corridor kept for display.
  • Behind estimate_same_building_anchor_enabled (default on); OFF = prior behavior.

Validation

Offline sim, 55 golden cases: range-covers-real 53%->95%, premium point-error 53%->18%, comfort 69%->100%, economy 50%->100% (no regression). Same-building comps exist in live DB for 47/55.
Live-DB self-check: Hohryakova 48 4k -> real 100M in [56.1,102.1]M; Olimp 13 penthouse -> real 207M in [74.5,258.9]M; Ilyicha 28 econ -> no inflation; 8 Marta 204G view -> real 15.95M in [7.5,16.2]M.

Test plan

  • 19 new unit tests; full suite 1106 passed (2 pre-existing deselects); ruff clean
  • live golden E2E (53 cases) post-merge

Known residual (next iter, not blocking): within-building floor/view dispersion (3/55) -> range spans it but wide for view-heavy buildings.

Refs #651 #652

## Summary Fixes the core accuracy bug: radius-median ppm2 systematically underestimated premium ~2.5x and comfort ~15-25% by diluting the building/complex premium. Replaces the radius median with a same-building anchor (industry-standard: Fannie Mae same-project-comps-preferred, similarity weighting, segment purity, premium guardrail, FSD range). - Tiered comps (first tier >=2): A same building (normalized street+house, relaxed rooms, no area filter, NOT grouped by house_id_fk) -> C <=500m same-segment -> D existing radius fallback. - Anchor = similarity-weighted mean ppm2 + guarded premium p70 uplift + ppm2-banded asking->sold haircut (4-7%) + hard guardrail (>= min same-building ppm2 x0.95) + tightened FSD range. - Address normalizer: e->e, alias Tkacheva->Tkachey, base-house-number across corpus letters. - Anchor PRIMARY when Tier A/C fires; IMV blend only in Tier D (no double-apply); expected_sold consistent; avito_imv + dkp_corridor kept for display. - Behind estimate_same_building_anchor_enabled (default on); OFF = prior behavior. ## Validation Offline sim, 55 golden cases: range-covers-real 53%->95%, premium point-error 53%->18%, comfort 69%->100%, economy 50%->100% (no regression). Same-building comps exist in live DB for 47/55. Live-DB self-check: Hohryakova 48 4k -> real 100M in [56.1,102.1]M; Olimp 13 penthouse -> real 207M in [74.5,258.9]M; Ilyicha 28 econ -> no inflation; 8 Marta 204G view -> real 15.95M in [7.5,16.2]M. ## Test plan - [x] 19 new unit tests; full suite 1106 passed (2 pre-existing deselects); ruff clean - [ ] live golden E2E (53 cases) post-merge Known residual (next iter, not blocking): within-building floor/view dispersion (3/55) -> range spans it but wide for view-heavy buildings. Refs #651 #652
bot-backend added 1 commit 2026-05-29 20:52:45 +00:00
Replaces radius-median ppm2 with a same-building anchor (Tier A: normalized
street+house comps; Tier C: <=500m segment-matched; Tier D: existing radius
fallback). Similarity-weighted mean + guarded premium uplift + ppm2-banded
asking->sold haircut + hard guardrail + tightened FSD range. Fixes ~2.5x
premium underestimate / 15-25% comfort dilution. Address normalizer handles
e->e, Tkacheva->Tkachey alias, base-house-number across corpus letters.
Behind estimate_same_building_anchor_enabled (default on); OFF = prior behavior.
Validated offline (55 golden: coverage 53->95%, premium medAPE 53->18%) + 4 live cases.
19 new tests; full suite 1106 passed; ruff clean.

Refs #651 #652
bot-reviewer approved these changes 2026-05-29 21:01:21 +00:00
bot-reviewer left a comment
Collaborator

Same-building anchor estimator v2 (#651/#652 v2), reviewed via subagent (6-dim). Verified: (1) #674 stale-expected_sold bug class CLEARED ? SB-anchor and IMV-blend are mutually exclusive (anchor_tier is None gate, no double-adjustment of median); expected_sold derived AFTER all mutations + DB persists post-mutation; consistency test present. (2) Math safe: exp-weights>0, wsum>0 guarded w/ percentile fallback, range_low floored >=0, range_low<=point<=range_high invariant, hard guardrail est>=comp_min*0.95, no div-by-zero. (3) SQL: CAST(:x AS type) binds, regex built only from int + single matched char (no injection). (4) Graceful-None degradation + comprehensive tests (flag on/off, anchor present/absent, premium-lift, economy no-overshoot, guardrail, expected_sold consistency). NOTE: flag estimate_same_building_anchor_enabled defaults ON (not OFF) ? this is the DOCUMENTED, golden-validated decision (vault 2026-05-30, real-in-range 53->95pct, premium 25->92pct, no comfort/economy regression), env-overridable kill-switch, matching merged sibling estimate_imv_blend_enabled=True. Accepting default-ON. APPROVE.

<!-- gendesign-review-bot: sha=bd7f404 verdict=approve --> Same-building anchor estimator v2 (#651/#652 v2), reviewed via subagent (6-dim). Verified: (1) #674 stale-expected_sold bug class CLEARED ? SB-anchor and IMV-blend are mutually exclusive (anchor_tier is None gate, no double-adjustment of median); expected_sold derived AFTER all mutations + DB persists post-mutation; consistency test present. (2) Math safe: exp-weights>0, wsum>0 guarded w/ percentile fallback, range_low floored >=0, range_low<=point<=range_high invariant, hard guardrail est>=comp_min*0.95, no div-by-zero. (3) SQL: CAST(:x AS type) binds, regex built only from int + single matched char (no injection). (4) Graceful-None degradation + comprehensive tests (flag on/off, anchor present/absent, premium-lift, economy no-overshoot, guardrail, expected_sold consistency). NOTE: flag estimate_same_building_anchor_enabled defaults ON (not OFF) ? this is the DOCUMENTED, golden-validated decision (vault 2026-05-30, real-in-range 53->95pct, premium 25->92pct, no comfort/economy regression), env-overridable kill-switch, matching merged sibling estimate_imv_blend_enabled=True. Accepting default-ON. APPROVE.
bot-reviewer merged commit 03a3296332 into main 2026-05-29 21:01:22 +00:00
bot-reviewer deleted branch feat/tradein-same-building-anchor 2026-05-29 21:01:22 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#677
No description provided.