Skip to content

reidjohnson/hpipy

Repository files navigation

hpiPy

PyPI - Version License GitHub Actions Codecov Code Style black

hpiPy simplifies and standardizes the creation of house price indices in Python.

The package provides tools to evaluate index quality through predictive accuracy, volatility, and revision metrics—enabling meaningful comparisons across different methods and estimators. It focuses on the most widely used approaches: repeat sales and hedonic pricing models, with support for base, robust, and weighted estimators where applicable. It also includes a random forest–based method paired with partial dependence plots to derive index components, as well as a neural network approach that separates property-specific and market-level effects to jointly estimate quality and index components from property-level data. Based on hpiR.

Quick Start

To install hpiPy from PyPI using pip:

pip install hpipy

Example

A basic example of creating a house price index:

import altair as alt
from hpipy.datasets import load_seattle_sales
from hpipy.price_index import RepeatTransactionIndex
from hpipy.utils.plotting import plot_index

# Load prepared data.
df = load_seattle_sales()

# Create an index.
hpi = RepeatTransactionIndex.create_index(
    trans_data=df,
    prop_id="pinx",
    trans_id="sale_id",
    price="sale_price",
    date="sale_date",
    periodicity="M",
    estimator="robust",
    log_dep=True,
    smooth=True,
)

# Visualize the index.
with alt.renderers.enable("browser"):
    plot_index(hpi, smooth=True).properties(title="Example Index", width=600).show()

Example Index Visualization

Documentation

An installation guide, API documentation, and examples can be found in the documentation.

Running the Tests

  1. Create a virtual environment (we recommend uv):
uv venv
  1. Install base and development dependencies:
uv pip install --requirements pyproject.toml --extra dev
  1. Run the test suite:
uv run pytest

Acknowledgements

Based on the hpiR package.