Sovereign 8s.is mirror of standardgalactic/Soil-PUE
  • Python 97%
  • Shell 3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-15 09:34:11 +08:00
solver Use seeds 42-54 and document EconML dependency 2026-07-27 15:03:28 +08:00
.gitignore Initial commit 2025-03-18 21:57:05 +08:00
CITATION.bib Update citation author list 2026-07-27 16:18:15 +08:00
ensemble.py Align ensemble workflow with five-model method 2026-08-15 09:34:11 +08:00
ensemble_comb_pred.py Align ensemble workflow with five-model method 2026-08-15 09:34:11 +08:00
main.py Use seeds 42-54 and document EconML dependency 2026-07-27 15:03:28 +08:00
read_shap.py Align ensemble workflow with five-model method 2026-08-15 09:34:11 +08:00
README.md Align ensemble workflow with five-model method 2026-08-15 09:34:11 +08:00
requirements.txt Add Python requirements file 2026-07-27 15:14:12 +08:00
run.sh Use seeds 42-54 and document EconML dependency 2026-07-27 15:03:28 +08:00
run_comb.sh Use seeds 42-54 and document EconML dependency 2026-07-27 15:03:28 +08:00
run_ensemble.sh Use seeds 42-54 and document EconML dependency 2026-07-27 15:03:28 +08:00

Soil-PUE

Official implementation of the 2026 Nature Food paper “Global patterns and feasible improvement potential of phosphorus use efficiency in cereal croplands.”

This repository contains the core machine-learning code used to model phosphorus use efficiency (PUE), compare tabular regression methods, construct the ensemble model, and evaluate cropland-management scenarios for maize, rice, and wheat.

Repository structure

  • main.py: trains and evaluates an individual model.
  • ensemble.py: evaluates the five-model ensemble and generates predictions.
  • ensemble_comb_pred.py: evaluates management-practice combinations with the ensemble model.
  • read_shap.py: processes SHAP outputs for model interpretation.
  • solver/: implementations of the supported regression models.
  • run.sh, run_ensemble.sh, and run_comb.sh: batch scripts used in the original computing environment.

The model pool includes Random Forest, XGBoost, LightGBM, CatBoost, Deep Forest, Auto-sklearn, MLP, CNN, ResNet, and FT-Transformer.

Environment

The experiments were developed with Python 3.9. We recommend creating an isolated Conda environment:

conda create -n soil-pue python=3.9
conda activate soil-pue

Install the Python dependencies with:

pip install -r requirements.txt

Weights & Biases is used for experiment tracking. Configure your account by following the Weights & Biases quickstart, or set WANDB_MODE=offline when running without online logging.

Running the code

To train and evaluate one model, run:

python main.py \
  --which-obj PUE \
  --model-name RandomForest \
  --seed 42

Available model names are:

RandomForest, AutoSklearn, XGBoost, LightGBM, CNN,
CatBoost, DeepForest, FTTransformer, MLP, ResNet

To enable hyperparameter optimization, add --optimize-hyperparams. The optimization method can be selected with --optimize-method BayesOpt or --optimize-method GridSearch.

After training CatBoost, Random Forest, Deep Forest, XGBoost, and LightGBM for the same seed, run the ensemble workflow with:

python ensemble.py --seed 42

The ensemble prediction is the unweighted arithmetic mean of the outputs from all five models.

The experiments use 13 consecutive random seeds, from 42 through 54 (inclusive). The batch scripts run this complete seed set. Review their GPU and concurrency settings before running them on a different system.

Data and model availability

The training data, global prediction inputs, and trained model checkpoints referenced by the scripts are not included in this public repository. For detailed source code, preprocessing and modeling information, trained models, data access, or other research materials, please contact the corresponding author.

Citation

If you use this repository in your research, please cite the paper:

@article{sun2026global,
  title   = {Global patterns and feasible improvement potential of phosphorus use efficiency in cereal croplands},
  author  = {Sun, Yishen and Hu, Han and Tan, Rong-Xi and Helfenstein, Julian and McDowell, Richard W. and Gu, Baojing and Ni, Haowei and Huang, Weigen and Ding, Jixian and Xue, Ke and Qian, Chao and Zhou, Jizhong and Zhou, Zhi-Hua and Zhang, Jiabao and Liang, Yuting},
  journal = {Nature Food},
  year    = {2026}
}

The volume, issue, page range, and DOI should be added when the final bibliographic record becomes available.

The same entry is available in CITATION.bib.

Contact

  • For questions about using the public code, please open a GitHub issue.
  • For detailed code, trained models, data, or scientific inquiries, please contact the corresponding author: Yuting Liang (ytliang@issas.ac.cn).