Tabular Regression
Scikit-learn
random-forest
scikit-learn
shap
explainable-ai
public-health
air-quality
Instructions to use oukawa/PRISMA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use oukawa/PRISMA with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("oukawa/PRISMA", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files12312345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394---
license: mit
------license: mitlibrary_name: sklearntags: - tabular-regression - random-forest - scikit-learn - shap - explainable-ai - public-health - air-quality---
# PRISMA: random forest models of respiratory hospital admissions in Curitiba and Araucária, Brazil
Code and trained models for the manuscript *Environmental and socioeconomic predictors of respiratory hospitaladmissions: An explainable machine learning approach* (under review in *Urban Climate*).
Random forest (RF) models predict hospital admissions for lower respiratory infections (LRI), chronic respiratorydiseases (CRD) and other respiratory conditions (Other) in Curitiba and Araucária (Paraná State, Brazil), 2003–2017,for four age groups. SHapley Additive exPlanations (SHAP) describe the contribution of each predictor.
- **Temporal models**: weekly admission rates for the city as a whole, from weather, climate indices, air pollutants, trend and season (24 predictors).- **Spatial models**: cumulative admissions on a 1-km grid, from socioeconomic variables, population density, road density and local climate zones (27 predictors).
The models describe associations learned from the data; SHAP values are not causal effects, and correlated predictors(e.g., temperature and season, or NOx, NO2 and CO) should be interpreted jointly.
## Files
| File | Content ||---|---|| `RF_temporal_{LRI,CRD,Other}_admissions_per_1_million_all_groups.pkl` | Main temporal models (M2, all 24 predictors) || `RF_spatial_{LRI,CRD,Other}_admissions_per_1_million_all_groups.pkl` | Main spatial models (S2, all 27 predictors) || `RF_temporal_training_and_cross-validation_all_diseases_and_groups.ipynb` | Blocked cross-validation, buffer test, nested models and lags, final models, grid search || `RF_spatial_training_and_cross-validation_all_diseases_and_groups.ipynb` | Spatially blocked cross-validation, nested models, final models, grid search || `RF_data_processing_temporal_and_spatial.ipynb` | Builds both input matrices following the manuscript (Sections 2.3.1–2.3.4, S1): weekly air quality, weather, climate indices and admission rates; 1-km grid with census, income, GDP, roads, LCZ and admissions |
Each `.pkl` holds a dict with one fitted `RandomForestRegressor` per age group, keyed `{disease}_{group}`, e.g.`LRI_General`, `LRI_G1`, `LRI_G2`, `LRI_G3`. Age groups: General (all ages), G1 (4 years and under), G2 (5–59 years)and G3 (60 years and over). Targets are admissions per 1 million inhabitants (per week for the temporal models;cumulative over 2003–2017 for the spatial models).
All models use 500 trees, a maximum depth of 20, all features at each split, a minimum of two samples to split anode, one sample per leaf and bootstrap sampling (Table S3).
## Usage
```pythonimport joblibimport pandas as pd
models = joblib.load('RF_temporal_LRI_admissions_per_1_million_all_groups.pkl')model = models['LRI_G1']print(list(model.feature_names_in_)) # predictor columns, in order# X: DataFrame with these columns -> weekly LRI admissions per 1 million inhabitants (children aged 4 and under)# pred = model.predict(X[model.feature_names_in_])```
The models were trained with scikit-learn 1.6.1 and re-saved with scikit-learn 1.8.0 (same trees; predictions agreewith the original files to within 1e-12). Loading them with another version raises a warning, and scikit-learn 1.8is recommended.
## Predictors
**Temporal** (weekly means unless noted): `t_min`, `t_max`, `t_mean`, `t_amp` (°C), `rh` (%), `ws` (m s-1),`insolation` (h), `evaporation` (mm), `rainfall` (mm, weekly total), `cdd`, `cwd`, `chd`, `ccd` (consecutive dry, wet,hot and cold days), `julian_day`, `unix_time` (s), `season_fall`, `season_spring`, `season_winter` (summer is thereference), `so2`, `no2`, `nox`, `o3`, `pm10` (µg m-3) and `co` (mg m-3).
**Spatial** (per 1-km cell): `WHT`, `BLK`, `YEL`, `BRN`, `IND` (% self-reported skin color/race), `LT` (% literate),`PD` (inhabitants km-2), `PCI` and `GDP` (USD per capita), `RD` (road density, km-1) and `LCZ_1`–`LCZ_10`,`LCZ_A`–`LCZ_G` (fraction of each local climate zone).
## Validation
- Temporal: month-per-season blocked cross-validation, six folds, with a 1-week buffer between training and test weeks (also tested with 0, 2 and 4 weeks).- Spatial: spatially blocked 5-fold cross-validation with 5 × 5 km blocks.
Scores, nested models, lags and errors by predictor tertile are reported in the Supplementary Material (Tables S2–S8).
## Data
The input matrices are not included. Hospital admissions are from DataSUS SIH, census data from IBGE (2010), the roadnetwork from OpenStreetMap, local climate zones from the LCZ Generator, and per capita GDP from Kummu et al. (2025).Air quality and weather data were obtained from IAT and INMET and cannot be shared. The notebooks document theexpected columns.
## License
MITREADME.md+94-3