Raw wildfire sensor data arrives with irregular distributions, extreme outliers, and right-censored survival targets. This section documents every cleaning and preprocessing decision taken before any model saw the data — from missing value handling to censoring-aware target construction.
Insights:
Both train and test have zero missing values across all 35 numeric feature columns. The competition dataset was pre-processed by the organizers before release.
WHY imputation was still written into the pipeline: Feature engineering creates derived quantities like eta = dist / closing_speed. If closing_speed is ever 0.0, this produces inf. If dist is 0, inv_distance = 1/(dist/1000 + 0.1) still works, but other combinations can silently produce NaN. The imputation step is a defensive line against these edge cases.
The exact code from the notebook: medians = train[num_cols].median() then train[num_cols].fillna(medians) and test[num_cols].fillna(medians). The key is that medians is computed once from training data and reused for test — test statistics never influence any imputation value.
WHY median over mean: Features like area_first_ha (fire size) are right-skewed — a few 10,000-hectare megafires drag the mean far above the typical fire. The median is the 50th percentile value, unaffected by those extremes, making it a safer fill value.
A second cleanup runs after feature engineering: df.replace([np.inf, -np.inf], np.nan).fillna(0) at the end of engineer_features. This catches any infinities produced by log or division operations on edge-case values that survived the first imputation pass.
Insights:
The target is not one column — it is two: event (did the fire hit?) and time_to_hit_hours (when?). GBSA consumes both together as a structured survival object via Surv.from_arrays(event=event_vals.astype(bool), time=time_vals). Removing either column breaks the model.
WHY GBSA needs the time column: Survival analysis ranks observations by how long they survived before the event. A fire that hit at hour 10 is more dangerous than one that hit at hour 60. Without the time dimension, both are just "event=1" and GBSA loses the ability to learn the speed dimension of the threat.
LightGBM cannot consume a survival object. Instead, make_binary_target(time, event, horizon) converts the survival data into a binary label per horizon: "did this fire hit by 12h? by 24h? by 48h?" — three separate binary problems, one model each.
The masking step is critical for LGB: mask = ~((event == 0) & (time < horizon)) removes rows where the fire was censored before the horizon. Example: a fire censored at hour 10 with horizon=24 is ambiguous — it might have hit at hour 15, we just don't know. Including it as a negative label would be wrong. These rows are dropped from LGB training only, not from GBSA (which handles censoring natively).
prob_72h is hardcoded to 1.0 in the final submission — final[:, 3] = np.ones(len(X_test)). WHY: By 72 hours, all observed fires in the training set have either hit or been censored at exactly 72h. The model has no information to distinguish fires at that horizon, and forcing 1.0 is consistent with the competition's scoring structure for the final window.
Insights:
Right-censoring means the outcome was not observed, not that it did not happen. A fire with event=0 and time_to_hit_hours=15 was still actively burning when the 15-hour snapshot was taken — we do not know if it hit at hour 16, hour 40, or never. Labelling it "safe" would introduce false negatives into training.
WHY this makes standard binary classification wrong: If you train a classifier with event=0 as the negative class, you are teaching the model that fires with high closing speed and short distance are "safe" — because many of those fires simply hadn't hit yet when the observation window closed. The model learns a distorted signal.
GBSA is derived from gradient boosting applied to the Cox proportional hazards model — it is mathematically designed to include censored observations in training without treating them as negatives. Censored rows contribute to the partial likelihood (they tell the model who was still "at risk" at each time point) without claiming the event did or did not occur.
The cumulative hit curve shows that most fires that will hit, hit before 48h. By 48h, the majority of eventual hits have already occurred. This is the empirical justification for the 48h Brier score receiving weight 0.4 — not an arbitrary competition choice but a reflection of where the real prediction uncertainty lies.
IPCW (Inverse Probability of Censoring Weights) in LightGBM addresses this from the calibration side: fires censored early are down-weighted because they had less exposure time, making their "0" label less reliable. compute_ipcw_weights in the notebook calculates these weights from the training fold only and passes them to LightGBM as sample_weight.
Insights:
StratifiedKFold(n_splits=5, shuffle=True, random_state=42) — these are the exact parameters from the notebook. Stratification is on event_vals, not on time, so each fold preserves the 31%/69% hit/censored ratio from the full dataset.
WHY stratify on event and not randomly split: With only 69 event=1 rows, a random split could produce a validation fold with 8 or 9 hits by chance. That fold would generate a noisy, unreliable Brier score. Stratification guarantees each fold has approximately 14 hits (69 ÷ 5), making every fold's score equally trustworthy.
WHY shuffle=True: The data may be ordered by event_id, which could correlate with geography or season. Without shuffling, fold 1 might contain only early-season fires and fold 5 only late-season fires. Shuffling breaks any accidental ordering before the split is made.
The same fold structure is used for both GBSA and LightGBM — both use StratifiedKFold(n_splits=5, shuffle=True, random_state=42) with the same event_vals as stratification key. This ensures both models are evaluated on the same fold boundaries, making their cross-validation scores directly comparable when selecting blend weights.
WHY 5 folds and not 10: With 221 rows, a 10-fold CV would leave only ~22 rows per validation fold — roughly 7 hits per fold. At that sample size, the Brier score estimate becomes too noisy to be useful for blend selection. 5 folds gives ~44 validation rows and ~14 hits per fold, which is the practical minimum for a reliable survival metric on this dataset.