Real Estate Hedonic Price Model · 부동산 헤도닉 가격모형 (한국)
공간 자기상관을 보정한 한국 아파트 실거래 헤도닉 가격모형 Hedonic pricing models for Korean apartment transactions with spatial autocorrelation correction
개요 · Overview
국내 부동산 분석은 공간 독립성 가정을 위배하는 단순 OLS 헤도닉 모형을 흔히 사용합니다. 강남권 아파트는 강한 공간 군집을 보이므로, 이를 무시하면 구조·근린·입지 속성의 잠재가격(implicit price) 추정이 편향됩니다. 본 저장소는 MOLIT 실거래가 수집부터 공간 헤도닉 추정·잠재가격 산출까지의 파이프라인을 제공합니다.
Korean real estate analysis commonly uses naive OLS hedonic models that violate spatial independence assumptions. Gangnam apartments exhibit strong spatial clustering — ignoring it biases implicit price estimates for structural, neighborhood, and locational attributes. This repository covers the full pipeline from MOLIT transaction collection to spatial hedonic estimation and implicit price reporting.
문제와 접근 · Problem & Approach
- 고전 헤도닉 / Classical Hedonic (Rosen, 1974) — OLS 기준선
- 공간 헤도닉 / Spatial Hedonic — SAR/SEM 보정 (PySAL/spreg,
models.py) - 잠재가격·MWTP / Implicit Prices — 한계지불의사액 산출
- MOLIT API 연동 / Data Pipeline — 실시간 실거래 수집 (
molit_api.py)
데이터 파이프라인 · Data Pipeline
MOLIT 실거래가 API → 정제 → 지오코딩(Kakao) → 공간조인(행정동)
→ 피처 엔지니어링 → 모형 추정 → 잠재가격 리포트
주요 변수 · Key Variables
| 구분 Category | 변수 Variables |
|---|---|
| 구조 Structural | 전용면적, 층, 연식, 세대수, 주차비율 |
| 근린 Neighborhood | 학군, 공원 근접성, 상업 밀도 |
| 교통 Transportation | 지하철 거리, 버스정류장 수, 도로 접근성 |
| 환경 Environmental | 소음, 조망, 경사, 침수위험구역 |
구현 현황 · Implementation Status
| 단계 | 함수 | 상태 | 검증 |
|---|---|---|---|
| MOLIT 실거래 수집·정규화·CSV 분할 | MolitClient, export_chunked_csv |
✅ | 응답 모킹 테스트 |
| 지오코딩 (캐시·속도제한·429/5xx 재시도) | KakaoGeocoder |
✅ | 가짜 세션 테스트 |
| 주소 조립 (시도·시군구 코드표) | build_full_address |
✅ | 서울 25개 구·전국 시도 |
| 전처리 (해제 제거·파생변수·구별 IQR·로그) | full_pipeline 외 9개 |
✅ | 교과서 IQR, 경계값 |
| 행정동 공간조인·EPSG:5186 투영 | spatial_join_dong, project_to_meter_crs |
✅ | 겹침 경계에서 행 수 보존 |
| 공간가중행렬·연결망 그림 | build_weights, plot_connectivity |
✅ | 단위 테스트 |
| OLS·SLM·SEM·SDM (최대우도, n>1000 은 희소 LU) | SpatialHedonicModel |
✅ | 모의자료 ρ·λ·β 복원 |
| 직접·간접·총효과 (대표본은 멱급수·확률 대각합) | impacts_decomposition |
✅ | β/(1−ρ) 항등식, 총효과 정확해와 1e-8 일치 |
| Moran's I · Geary's C · LISA · LM 진단 | diagnostics.py |
✅ | SLM·SEM 자료 판별, 귀무하 오추천률 |
| 시각화 5종 | visualization.py |
✅ | 스모크 테스트 |
| 대시보드 (Streamlit) | dashboard/app.py |
✅ | 로더 테스트 |
오프라인 시연 · Offline Demo
API 키 없이 notebooks/02_offline_simulation_demo.ipynb로 전체 흐름을 실행할 수 있습니다 (실행 결과 포함). 참값을 아는 모의 실거래 850건에서:
| 참값 | OLS | SEM | |
|---|---|---|---|
| 연식 효과 (/년) | −0.0080 | −0.0081 | −0.0083 |
| 층 효과 (/층) | +0.0040 | +0.0032 | +0.0040 |
| 잔차 Moran's I | — | 0.957 | 0.005 |
LM 진단(Robust LM-Error 3022 ≫ Robust LM-Lag 16)과 AIC 모두 자료생성과정과 같은 SEM 을 고릅니다.
from hedonic import full_pipeline, build_weights, SpatialHedonicModel, lm_diagnostics
ads = full_pipeline(raw) # MOLIT 정규화 자료 + 좌표
w = build_weights(ads, method="knn", k=15)
ols = SpatialHedonicModel(ads, "log_price", ["log_area", "building_age", "floor"], w=w).fit()
best = lm_diagnostics(ols, w).recommend() # 'OLS' | 'SLM' | 'SEM'
print(SpatialHedonicModel(ads, "log_price", ["log_area", "building_age", "floor"], w=w,
method=best).fit().summary())
기술 스택 · Tech Stack
- Core: Python 3.11+, pandas, requests (수집만 쓰면 이것으로 충분)
- 공간계량 (
[spatial]): PySAL (libpysal·spreg·esda), GeoPandas, pyproj, matplotlib - 대시보드 (
[dashboard]): Streamlit, Plotly - 데이터 수집: MOLIT 실거래가 API, Kakao Local 지오코딩
프로젝트 구조 · Repository Structure
real-estate-hedonic/
├── src/hedonic/
│ ├── molit_api.py # MOLIT 실거래가 API 래퍼
│ ├── geocoding.py # Kakao/V-World 지오코딩
│ ├── preprocessing.py # 정제·공간조인·피처 생성
│ ├── weights.py # 공간 가중행렬
│ ├── models.py # OLS·SLM·SEM·SDM 헤도닉, 효과 분해
│ ├── diagnostics.py # 공간 진단·검정
│ └── visualization.py # 가격지도·결과 시각화
├── dashboard/
│ ├── app.py # 인터랙티브 대시보드
│ └── loader.py
├── scripts/
│ ├── fetch_molit.py # 실거래 수집
│ ├── fetch_bulk.py # 대량 수집
│ ├── build_seoul_geo.py # 서울 경계 GeoJSON 구축
│ └── make_sample.py # 샘플 데이터 생성
├── notebooks/
│ ├── 01_end_to_end_pipeline.ipynb # 실데이터 (API 키 필요)
│ └── 02_offline_simulation_demo.ipynb # 오프라인 시연 (실행 결과 포함)
├── data/{raw, sample}/
├── docs/ARCHITECTURE.md
├── tests/ # 93개 테스트, 커버리지 90% 미만이면 CI 실패
├── pyproject.toml · requirements.txt
└── LICENSE
빠른 시작 · Quick Start
git clone https://github.com/DongsooJung/real-estate-molit-api.git
cd real-estate-molit-api
pip install -e ".[dev,spatial,dashboard]" # 수집만이면 pip install -e .
pytest --cov --cov-fail-under=90
# MOLIT API 키 설정 (.env.example 참고)
export MOLIT_API_KEY="your_key_here"
export KAKAO_REST_API_KEY="your_key_here" # 지오코딩
jupyter notebook notebooks/01_end_to_end_pipeline.ipynb
참고문헌 · References
- Rosen, S. (1974). Hedonic Prices and Implicit Markets. JPE.
- Can, A. (1992). Specification and Estimation of Hedonic Housing Price Models. Regional Science and Urban Economics.
- 국토교통부. 실거래가 공개시스템 API 문서.
라이선스 · License
MIT License
저자 · Author
정동수 (Dongsoo Jung) — 서울대학교 박사과정 · 스마트도시공학 연구 분야: 공간계량 × 부동산 × 도시정책
Metadata
Release files for real-estate-hedonic 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| real_estate_hedonic-0.2.0.tar.gz | 46.3 kB | With provenance | Details for real_estate_hedonic-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| real_estate_hedonic-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for real_estate_hedonic-0.2.0-py3-none-any.whl |
Total release size: 80.7 kB
Release files / real_estate_hedonic-0.2.0.tar.gz
| Download URL | real_estate_hedonic-0.2.0.tar.gz |
|---|---|
| Size | 46.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
908aa6bf535fbc5bb08119b95868aac65f17e47b9e36f81ac7e624d7a1d362e3
|
|
BLAKE2b-256 checksum How to use checksums |
89d21c4fa4e370618cbb7059709c05070aeb8b64704588a0858a50d8002c2f72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.
Transparency logRelease files / real_estate_hedonic-0.2.0-py3-none-any.whl
| Download URL | real_estate_hedonic-0.2.0-py3-none-any.whl |
|---|---|
| Size | 34.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20bcc4a3a146e285511e9a01c0f6c70a6a0145de0c7caefbe8ef2264671c2dae
|
|
BLAKE2b-256 checksum How to use checksums |
914654cf6e0b21c3f6aed4d42d6bf24f1e675640cfc5c11ca820f01b0a3644c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.
Transparency logSecurity for real-estate-hedonic 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for real_estate_hedonic-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.