hpipy.extensions.NeuralNetworkModel#

class hpipy.extensions.NeuralNetworkModel(hpi_data, **kwargs)[source]

Bases: BaseHousePriceModel

Neural network house price model.

Methods

__init__

Initialize base house price model.

fit

Fit the neural network model and generate index coefficients.

Attributes

Parameters:
  • hpi_data (TransactionData)

  • kwargs (Any)

fit(dep_var, ind_var, date, estimator='residual', log_dep=True, feature_dict=None, num_models=5, num_epochs=20, batch_size=1024, hidden_dims=None, emb_size=5, dropout_rate=0.1, learning_rate=0.001, do_mixup=False, preprocess_time=True, preprocess_geo=True, geo_resolutions=None, min_pred_epoch=16, quantile=0.5, random_seed=0, verbose=False)[source]

Fit the neural network model and generate index coefficients.

The model supports two distinct approaches for extracting the house price index, controlled by the estimator parameter:

  1. “residual”: This approach extracts the index directly from the market pathway of the neural network. It works by zeroing out all of the neural network. It works by zeroing out all non-temporal features and examining the network’s output, effectively isolating the temporal component of price changes. This method is more direct and computationally efficient.

  2. “attributional”: This approach derives the index through explainability analysis of both market and time components. It uses attribution techniques to decompose the network’s predictions and quantify how much of the price change can be attributed to temporal factors versus other market characteristics. This method provides more detailed insights into price drivers but is computationally more intensive.

Parameters:
  • dep_var (str) – Dependent variable.

  • ind_var (list[str]) – Independent variable(s).

  • date (str) – Date column name.

  • estimator (str, optional) – Estimator type. Choose between “residual” (extracts index from market pathway) or “attributional” (derives index through explainability). Defaults to “residual”.

  • log_dep (bool, optional) – Log transform the dependent variable. Defaults to True.

  • feature_dict (dict[str, list[str]] | None, optional) – Feature dictionary. Defaults to None.

  • num_models (int, optional) – Number of models in the ensemble. Defaults to 5.

  • num_epochs (int, optional) – Number of epochs to train. Defaults to 20.

  • batch_size (int, optional) – Batch size for training. Defaults to 1024.

  • hidden_dims (int | list[int] | None, optional) – Hidden layer sizes. If None, defaults to [128, 32].

  • emb_size (int, optional) – Output size for each embedding. Defaults to 5.

  • dropout_rate (float, optional) – Dropout rate for training. Defaults to 0.1.

  • learning_rate (float, optional) – Learning rate for training. Defaults to 1e-3.

  • do_mixup (bool, optional) – Perform mixup augmentation. Defaults to False.

  • preprocess_time (bool, optional) – Preprocess temporal features from sale date column. Defaults to True.

  • preprocess_geo (bool, optional) – Preprocess geospatial features from latitude and longitude columns. Defaults to True.

  • geo_resolutions (int | list[int] | None, optional) – Geospatial (H3) cell resolutions. If None, defaults to [6, 7].

  • min_pred_epoch (int, optional) – Minimum prediction epoch. If None, defaults to 16.

  • quantile (float, optional) – Quantile to estimate. If None, defaults to 0.5.

  • random_seed (int, optional) – Random seed to use. Defaults to 0.

  • verbose (bool, optional) – Verbose output. Defaults to False.

Returns:

Fitted model.

Return type:

Self

__init__(hpi_data, **kwargs)

Initialize base house price model.

Parameters:
  • hpi_data (TransactionData)

  • kwargs (Any)

Return type:

None

coefficients: DataFrame
model_obj: Any
periods: DataFrame
base_price: float
params: dict[str, Any]