hpipy.price_model.RepeatTransactionModel#
- class hpipy.price_model.RepeatTransactionModel(hpi_data, **kwargs)[source]
Bases:
BaseHousePriceModel
,TimeMatrixMixin
Repeat transaction house price model.
Methods
Initialize base house price model.
Create a time matrix from a dataframe of repeat transactions.
Fit the repeat transaction model and generate index coefficients.
Attributes
- Parameters:
hpi_data (TransactionData)
kwargs (Any)
- fit(estimator='base', log_dep=True, **kwargs)[source]
Fit the repeat transaction model and generate index coefficients.
- __init__(hpi_data, **kwargs)
Initialize base house price model.
- Parameters:
hpi_data (TransactionData)
kwargs (Any)
- Return type:
None
- create_time_matrix(repeat_trans_df)
Create a time matrix from a dataframe of repeat transactions.
This function assumes the dataframe contains columns “period_1” and “period_2” that represent a pair of repeat transactions. The resulting dataframe consists of rows for each transaction pair and columns for each time period, with -1 indicating the first transaction in a pair, 1 indicating the second transaction in a pair, and 0 otherwise.
- Parameters:
repeat_trans_df (pd.DataFrame) – Input DataFrame. Must contain “period_1” and “period_2” columns containing integer values representing periods (i.e., time series expressed as integer).
- Returns:
- DataFrame with columns ‘time_x’, where each row
represents a transaction pair and ‘x’ is a time period between the minimum and maximum periods in the input data.
- Return type:
pd.DataFrame
- coefficients: DataFrame
- model_obj: Any
- periods: DataFrame
- base_price: float