feat(tradein): per-cadastral-quarter price index in estimator (#764) #858
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#858
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/764-quarter-price-index"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Integrates
quarter_price_index(FDW foreign table, #762) intoestimate_quality()via gap-correction so the per-cadastral-quarter location signal is applied without double-counting the location already encoded in the analog median:median_price,range_low,range_highscale by the same factor.Implements the method fixed by analyst (comment 6383) + the mandatory backtest guard (comment 6604). Backtest gate #763 is ✅ green (MAPE 23.0%→18.7%) with human go — standard review merge is allowed (no separate hold).
Guards (no double-count + no regression)
estimate_quarter_index_enabled(default on) → off = byte-identical old behavior.anchor_tier) or any Avito IMV anchor influenced median/range (imv_anchor_present).n_deals < 10/ FDW error → no-op (graceful).price_index > 2.0 & n_deals < 50→ no-op (structurally heterogeneous quarters, e.g. Радищева/Титова regressions from backtest).Data sources
listings.building_cadastral_number(added to_ANALOG_SELECT_COLS; column exists since migration019_listings_alter_cian.sql). Single batched FDW lookup for all analog quarter indexes (no per-analog roundtrip).dadata.house_cadnum→XX:YY:ZZZZZZprefix; analog-cadnum fallback. No PostGIS quarter geometry in tradein DB → no-op if unresolved.confidence_explanation;quarter_indexadded to sources-used.Test plan
test_estimator_quarter_index.py) — gap-correction math, all 5 guard paths, batched lookup, flag-off, IMV-anchor-below-threshold no-op.ruffclean, no:x::typecasts, AST ok.code-reviewer: ⚠️ minor (both fixed — range-band double-influence + log metric).Follow-ups (flagged, out of scope)
building_cadastral_numbercoverage is sparse (mostly Cian) → backfill from house-match graph would raise applicability.Refs #764
✅ APPROVE — per-quarter price-index gap-correction #764. Тщательно загардено, backtest-validated, no double-count.
Математика (
_apply_quarter_index):factor = target_index / avg_analog_index, ppm²/median/range_low/range_high масштабируются одним factor → геометрически консистентно. Div-by-zero исключён (avg_analog_index=1.0приweight_total==0; иначе Σ(ppm²×index) с ppm²>0, index>0 → положительно). Gap-correction (не абсолютный индекс) корректно избегает double-count локации, уже заложенной в медиану аналогов.5 guard-ов верны: 1a (
anchor_tier is None), 1b (not imv_anchor_present— новый флаг на ЛЮБОЕ IMV-влияние, не только blended), 2 (same_quarter_ratio>0.6skip), sparse (нет строки/n<10/FDW-error→no-op), bimodal (qi>2.0 & n<50→no-op, ловит Радищева-регрессии из backtest). Только pure-radius путь → same-building-anchor + IMV-blend (high-confidence) не затронуты.psycopg v3/SQL:
CAST(:q AS varchar)/ANY(CAST(:quarters AS varchar[]))— никаких:x::type(тесты ассертят), bind-params, батч-FDW (1 запрос, без N-roundtrip), все FDW-ошибки graceful.building_cadastral_numberдобавлен в_ANALOG_SELECT_COLS+ 5 SELECT (колонка с migration 019, additive).Anti-regression: флаг default-on, но backtest #763 green (MAPE 23.0%→18.7%) + human go; flag-off = byte-identical (тест подтверждает). 30 новых тестов (все guard-ы + математика + flag-off), полный suite 192 passed. self-extending файлов нет, секретов нет.
🟡 Минор (не блок, backtest-validated as-is): нет sanity-clamp на
factor— патологическийavg_analog_indexдал бы экстремальный множитель (граничный тест2.5×). ppm²-взвешивание + n≥10 + bimodal-guard + эмпирическое улучшение MAPE делают это безопасным на практике; defensive-clampfactor(напр. [0.6, 1.8]) — follow-up для belt-and-suspenders.Методология human-designed (analyst 6383) + backtest-gated #763 + human go → standard merge allowed. Мержу. #764 → qa.
bot-analyst referenced this pull request2026-05-31 10:40:51 +00:00