| import pandas as pd |
| from src.features.geo_features import LondonPropertyGeoFeatures |
| |
| |
| |
|
|
| def is_numeric_and_true(value): |
| return isinstance(value, (int, float)) and bool(value) |
|
|
|
|
| def build_features(df: pd.DataFrame, geo_dir: str = "data/geo") -> pd.DataFrame: |
| """ |
| Compute all features used by the rent price model. |
| Combines geospatial, engineered, and NLP-derived features. |
| """ |
|
|
| |
| geo = LondonPropertyGeoFeatures(geo_dir) |
| df = geo.add_features_to_df(df) |
|
|
| |
| |
|
|
| |
| |
| |
|
|
| df["deposit"] = df["deposit"].apply(is_numeric_and_true) |
|
|
| return df |
|
|
|
|
|
|