""" Shared configuration for the Building-Age-Classification hackathon (Madrid -> Amsterdam transfer). Everything that both the GBDT track and the LLM track need lives here so the two never disagree about class boundaries, feature names or file paths. """ from __future__ import annotations import os from pathlib import Path # --------------------------------------------------------------------------- # # 1. Paths (work on a laptop, on Kaggle and on Colab without edits) # --------------------------------------------------------------------------- # def _detect_platform() -> str: if os.path.exists("/kaggle/working"): return "kaggle" try: # noqa: SIM105 import google.colab # noqa: F401 return "colab" except Exception: return "local" PLATFORM = _detect_platform() if PLATFORM == "kaggle": PROJECT_ROOT = Path("/kaggle/working") DATA_DIR = Path("/kaggle/input") # the attached dataset lives here elif PLATFORM == "colab": PROJECT_ROOT = Path("/content/hack4dev") DATA_DIR = PROJECT_ROOT / "data" else: PROJECT_ROOT = Path(__file__).resolve().parent.parent DATA_DIR = PROJECT_ROOT / "data" RAW_DIR = DATA_DIR / "raw" PROC_DIR = DATA_DIR / "processed" REPORT_DIR = PROJECT_ROOT / "results" # "reports" in the original project for _d in (PROC_DIR, REPORT_DIR): try: _d.mkdir(parents=True, exist_ok=True) except Exception: pass RANDOM_SEED = 42 # --------------------------------------------------------------------------- # # Hugging Face settings for the LLM track (notebooks 2, 4, 5). That track is # not part of this release; nothing here uses these names. # --------------------------------------------------------------------------- # HF_USER = os.environ.get("HF_USER", "Karar-git") DATASET_REPO = f"{HF_USER}/building-age-prompts" MODEL_REPO_PREFIX = f"{HF_USER}/" def hf_ready() -> bool: return bool(HF_USER) and HF_USER != "YOUR_HF_USERNAME" # --------------------------------------------------------------------------- # # 2. The task definition (from the organisers' Notebook 1 / 3) # --------------------------------------------------------------------------- # BASE_BANDS = ["Blue", "Green", "Red", "NIR", "SWIR1", "SWIR2"] INDEX_COLS = ["NDVI", "NDBI", "UI", "MNDWI", "BSI"] # Landsat Collection-2 Level-2 surface-reflectance scaling: SR = DN*2.75e-5 - 0.2 SR_SCALE, SR_OFFSET = 2.75e-5, -0.2 BLUE_MAX = 15_000 # haze threshold from the organisers' Notebook 2 EARLY_CUTOFF = 2003 # early period = 1984..2003 LATE_START = 2004 # late period = 2004.. PID = ["px_key", "py_key"] # City-specific boundary between class 1 and class 2 CLASS_EVENTS = {"Amsterdam": 1945, "Madrid": 1960} CLASS_LABELS = { "Amsterdam": {1: "before 1945", 2: "1945-1984", 3: "1984-2004", 4: "2004-2024"}, "Madrid": {1: "before 1960", 2: "1960-1984", 3: "1984-2004", 4: "2004-2024"}, } # Published class shares (organisers' guide) - used only for sanity checks, # never to fit anything. PUBLISHED_SHARES = {"Madrid": {2: 0.356}, "Amsterdam": {4: 0.111}} # --------------------------------------------------------------------------- # # 3. The official 60 features, in the official order # --------------------------------------------------------------------------- # FEAT_OVERALL = [f"{b}_mean" for b in BASE_BANDS] + [f"{b}_std" for b in BASE_BANDS] FEAT_INDICES = [f"{i}_mean" for i in INDEX_COLS] + [f"{i}_std" for i in INDEX_COLS] FEAT_EARLY = [f"{b}_early_mean" for b in BASE_BANDS] + [f"{b}_early_std" for b in BASE_BANDS] FEAT_LATE = [f"{b}_late_mean" for b in BASE_BANDS] + [f"{b}_late_std" for b in BASE_BANDS] FEAT_YOY = [f"d_{b}_mean" for b in BASE_BANDS] + [f"d_{b}_std" for b in BASE_BANDS] FEAT_IND = ["has_early_data", "has_late_data"] FEATURE_COLS_60 = FEAT_OVERALL + FEAT_INDICES + FEAT_EARLY + FEAT_LATE + FEAT_YOY + FEAT_IND FEAT_GROUPS_60 = { "overall": FEAT_OVERALL, "indices": FEAT_INDICES, "early": FEAT_EARLY, "late": FEAT_LATE, "yoy": FEAT_YOY, "indicators": FEAT_IND, } assert len(FEATURE_COLS_60) == 60, len(FEATURE_COLS_60)