How sustainlab-group/sustainbench works
Purpose and Entry Points
SustainBench is a Python benchmark-data package for SDG-focused ML tasks, exposing PyTorch-ready dataset loaders rather than an application service. Primary access points are dataset retrieval/selection in sustainbench/get_dataset.py and sustainbench/download_datasets.py; package metadata begins at sustainbench/__init__.py and setup.py.
Dataset Abstraction Layer
The central dataset contract is defined by sustainbench/datasets/sustainbench_dataset.py. Task-specific implementations specialize it for DHS/poverty, crop segmentation/yield/type mapping, brick-kiln imagery, and fMoW land-cover tasks:
• sustainbench/datasets/dhs_dataset.py
• sustainbench/datasets/crop_seg_dataset.py
• sustainbench/datasets/fmow_dataset.py
This is the principal boundary between downloaded, task-specific on-disk artifacts and model-facing tensors/labels.
Acquisition and Dataset Routing
s u s t a i n b e n c h / d o w n l o a d _ d a t a s e t s . p y (path: sustainbench/download_datasets.py) obtains processed benchmark data; sustainbench/datasets/download_utils.py contains shared download behavior. sustainbench/get_dataset.py resolves user-requested datasets to concrete loader implementations. Processed data is externally hosted on Google Drive, while raw data and preprocessing inputs are intentionally outside the normal training path.
Training/Evaluation Support
Common ML plumbing is shared across loaders and downstream baselines:
• sustainbench/common/data_loaders.py
• sustainbench/common/grouper.py
• sustainbench/common/metrics/all_metrics.py
The grouper and metrics layers support consistent aggregate and group-aware benchmark evaluation across heterogeneous task types. Loss and metric abstractions live under sustainbench/common/metrics/.
DHS/LSMS Label Production Pipeline
The most substantial data-creation workflow builds survey-derived labels for poverty, health, education, water, and sanitation. R scripts create DHS and LSMS labels, with notebooks exporting and processing TFRecords:
• dataset_preprocessing/dhs_lsms/1_create_dhs_labels.R
• dataset_preprocessing/dhs_lsms/1_create_lsms_labels.R
• dataset_preprocessing/dhs_lsms/2_export_tfrecords.ipynb
DHS cleanup/recode rules and LSMS country harmonization are separate source boundaries in dataset_preprocessing/dhs_lsms/dhs_utils/cleaning_utils.R and dataset_preprocessing/dhs_lsms/lsms_utils/. Final DHS outputs are materialized under dataset_preprocessing/dhs_lsms/output_labels/.
Geospatial and Other Preprocessing
DHS record-to-imagery preparation includes Earth Engine support in dataset_preprocessing/dhs_lsms/ee_utils.py; TFRecord export/processing establishes a TensorFlow-era intermediate format. Brick-kiln CSV preparation is isolated in dataset_preprocessing/brickkiln_csv_processing.ipynb. These workflows produce release artifacts consumed later by Python loaders, not runtime dependencies for ordinary users.
Runtimes and Infrastructure
The repository spans Python 3.7, PyTorch 1.9 for loaders/models, TensorFlow 1.15 for preprocessing/TFRecords, and R 4.1 for survey label engineering. Conda environment definitions are env_bench.yml and dataset_preprocessing/env_create.yml. GPU execution is optional, with CUDA/cuDNN requirements noted for accelerated TensorFlow/PyTorch workloads; Google Drive is the primary external dataset distribution service.
Main entry points: sustainbench_dataset.py Dataset contract · get_dataset.py Dataset selector · dhs_dataset.py Task dataset loaders · 2_export_tfrecords.ipynb TFRecord export
Components 19
Python benchmark package
- Package metadata
sustainbench/__init__.py - Installation metadata
setup.py - Dataset selector · Resolves requested benchmark datasets to concrete loaders.
sustainbench/get_dataset.py - Dataset retrieval · Obtains processed benchmark releases.
sustainbench/download_datasets.py - Download utilities
sustainbench/datasets/download_utils.py
Dataset runtime
- Dataset contract · Boundary from on-disk artifacts to model-facing tensors and labels.
sustainbench/datasets/sustainbench_dataset.py - Task dataset loaders · DHS, crop, brick-kiln, and fMoW task specializations.
sustainbench/datasets/dhs_dataset.py - Crop segmentation loader
sustainbench/datasets/crop_seg_dataset.py - fMoW loader
sustainbench/datasets/fmow_dataset.py - ML data loaders
sustainbench/common/data_loaders.py - Group evaluation
sustainbench/common/grouper.py - Metrics · Provides aggregate and group-aware benchmark metrics.
sustainbench/common/metrics/all_metrics.py
Release-data preprocessing
Offline workflows produce artifacts for package loaders.
- DHS and LSMS labels · Creates poverty, health, education, water, and sanitation labels.
dataset_preprocessing/dhs_lsms/1_create_dhs_labels.R - Survey cleanup and harmonization · DHS recoding and LSMS country harmonization inputs.
dataset_preprocessing/dhs_lsms/dhs_utils/cleaning_utils.R - TFRecord export · Exports and processes survey data into a TensorFlow-era intermediate.
dataset_preprocessing/dhs_lsms/2_export_tfrecords.ipynb - DHS imagery preparation
dataset_preprocessing/dhs_lsms/ee_utils.py - Survey release artifacts
- Brick-kiln CSV preparation · Offline preparation for brick-kiln release artifacts.
dataset_preprocessing/brickkiln_csv_processing.ipynb
Other components
- Processed dataset releases · External distribution for processed benchmark data.
Connections 18
- Package metadata → Installation metadata: packaged by
- Dataset selector → Task dataset loaders: selects
- Dataset selector → Crop segmentation loader: selects
- Dataset selector → fMoW loader: selects
- Task dataset loaders → Dataset contract: specializes
- Crop segmentation loader → Dataset contract: specializes
- fMoW loader → Dataset contract: specializes
- ML data loaders → Dataset contract: batches
- Group evaluation → Metrics: supports group-aware evaluation
- Dataset retrieval → Download utilities: uses
- Download utilities → Processed dataset releases: downloads from
- Dataset retrieval → Task dataset loaders: provisions artifacts for
- Survey cleanup and harmonization → DHS and LSMS labels: supplies recoding rules
- DHS and LSMS labels → TFRecord export: provides survey labels
- DHS imagery preparation → TFRecord export: prepares imagery records
- TFRecord export → Survey release artifacts: materializes
- Survey release artifacts → Processed dataset releases: published as release data
- Brick-kiln CSV preparation → Processed dataset releases: publishes release artifacts