hpipy.extensions.RandomForestIndex#
- class hpipy.extensions.RandomForestIndex(**kwargs)[source]
Bases:
HedonicIndex
Random forest house price index.
Estimates the relationship between independent and dependent variables using a random forest model. Extracts the coefficients of temporal variables to represent the marginal contribution of each time period. Explainability methods are used to assess the conditional marginal impact of each time period on price changes, which are converted into an index.
Methods
Initialize base house price index.
Convert coefficients to an index.
Create the index.
Create a series from the index.
Create an index from a house price model.
Get hedonic transaction data.
Get a random forest house price model.
Smooth the index.
Apply smoothing to all indices.
Attributes
- Parameters:
kwargs (Any)
- static get_model()[source]
Get a random forest house price model.
- Return type:
type[BaseHousePriceModel]
- __init__(**kwargs)
Initialize base house price index.
- Parameters:
kwargs (Any)
- Return type:
None
- static coef_to_index(coef_df, log_dep, base_price=1)
Convert coefficients to an index.
- classmethod create_index(trans_data, prop_id=None, trans_id=None, price=None, seq_only=True, max_period=None, smooth=False, periodicity=None, min_date=None, max_date=None, adj_type=None, **kwargs)
Create the index.
- Parameters:
trans_data (TransactionData | PeriodTable | pd.DataFrame) – Input transaction data.
prop_id (str | None, optional) – Property identifier. Defaults to None.
trans_id (str | None, optional) – Transaction identifier. Defaults to None.
price (str | None, optional) – Price column name. Defaults to None.
seq_only (bool, optional) – Sequential only. Defaults to True.
max_period (int | None, optional) – Maximum index period. Defaults to None.
smooth (bool, optional) – Smooth the index. Defaults to False.
periodicity (str | None, optional) – Periodicity of the index. Defaults to None.
min_date (str | None, optional) – Minimum date for the index. Defaults to None.
max_date (str | None, optional) – Maximum date for the index. Defaults to None.
adj_type (str | None, optional) – Adjustment type. Defaults to None.
**kwargs – Additional keyword arguments.
- Returns:
Index object.
- Return type:
Self
- create_series(train_period=12, max_period=None, **kwargs)
Create a series from the index.
- classmethod from_model(model, trans_data=None, max_period=None, smooth=False, **kwargs)
Create an index from a house price model.
- Parameters:
model (BaseHousePriceModel) – House price model object.
trans_data (TransactionData | None, optional) – Transaction data object. Defaults to None.
max_period (int | None, optional) – Maximum period for the index. Defaults to None.
smooth (bool, optional) – Smooth the index. Defaults to False.
**kwargs – Additional keyword arguments.
- Returns:
Index object.
- Return type:
Self
- static get_data()
Get hedonic transaction data.
- Return type:
type[TransactionData]
- smooth_index(order=3, in_place=False)
Smooth the index.
- smooth_series(order=3)
Apply smoothing to all indices.
- Parameters:
order (int) – Defaults to 3.
- Returns:
Index object.
- Return type:
Self
- data: TransactionData
- model: BaseHousePriceModel
- name: pd.Series
- periods: pd.Series
- value: pd.Series
- index: Any
- imputed: np.ndarray
- smooth: Any
- accuracy: pd.DataFrame
- accuracy_smooth: pd.DataFrame
- volatility: pd.DataFrame
- volatility_smooth: pd.DataFrame
- revision: pd.DataFrame
- revision_smooth: pd.DataFrame