PROJECT 096 · PYTHON SOURCE
Burned-area severity benchmark
Study-specific code. Shared modules, dependency versions, and reproduction instructions are included in all project files.
Download Python file ↓from pathlib import Path
import sys
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT))
import numpy as np
import pandas as pd
from scipy.stats import spearmanr
from sklearn.decomposition import PCA
from sklearn.ensemble import IsolationForest
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import confusion_matrix, precision_score, recall_score
from portfolio.data import load
from portfolio.constants import *
from portfolio.methods import result, sql, rates, associations, distribution, regression, classification, cluster
from portfolio.engine import execute
META = {'id': 96, 'dataset': 'fires', 'title': 'Burned-area severity benchmark', 'question': 'Can recorded conditions estimate burned area beyond a simple baseline?', 'method': 'Grouped-input regression on log1p area, inverse-transformed before original-unit scoring.', 'action': 'Use disappointing as well as successful benchmarks to define what additional event data are needed.', 'limitations': 'The sample consists of recorded fire observations, not all places and times at risk. Zero recorded area is not evidence of no ignition. No precise dates or event identifiers are supplied. This is not an emergency forecasting system. '}
def analyze():
df = load('fires').copy()
features=['x','y','month','day','ffmc','dmc','dc','isi','temp','rh','wind','rain']
t,p,e=regression(df,features,'area',log_target=True)
out=result(t,'model','mae','Hectares MAE','This models severity conditional on a recorded observation, not fire occurrence. Log predictions can understate rare large areas; compare RMSE as well as MAE.',extra={'predictions':p},evaluation=e)
return out
if __name__ == "__main__":
execute(Path(__file__).parent, META, analyze)