Instructions to use food-ai-nexus/soil-listeria-baseline with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use food-ai-nexus/soil-listeria-baseline with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("food-ai-nexus/soil-listeria-baseline", "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
Soil Listeria Baseline Model
A LightGBM binary classifier that predicts Listeria presence in soil samples from geochemical, environmental, and land-use features. This is the official baseline model for the soil-listeria-us-land leaderboard.
Model Description
| Property | Value |
|---|---|
| Algorithm | LightGBM (LGBMClassifier) |
| Task | Binary classification β Listeria detected (1) vs. not detected (0) |
| Dataset | food-ai-nexus/soil-listeria-us-land |
| Input features | Soil geochemistry, climate, and land-use variables |
| Engineered features | cn_ratio (total carbon / total nitrogen), temperature_range (max - min temperature) |
| Decision threshold | 0.36 (tuned on out-of-fold predictions) |
The dataset originates from a US-wide soil survey linking soil properties to Listeria isolation. Positive labels correspond to samples where at least one Listeria isolate was recovered.
Training Procedure
Feature engineering β Two domain-motivated features are added:
cn_ratio = total_carbon_pct / total_nitrogen_pct(with inf/NaN handling via median imputation)temperature_range = max_temperature_c - min_temperature_c- Any remaining NaN values are filled with column medians.
Hyperparameter search β
RandomizedSearchCV(100 iterations) over both XGBoost and LightGBM, scored by F1, using 5-fold stratified CV (random_state=42).Model selection β The model with the highest mean CV F1 is selected.
Threshold tuning β Out-of-fold predicted probabilities from the best model are used to sweep thresholds from 0.30 to 0.70 (step 0.01), maximizing F1.
Final retraining β The selected model is retrained on the full training set with the best hyperparameters.
Best Hyperparameters (LightGBM)
| Parameter | Value |
|---|---|
boosting_type |
gbdt |
n_estimators |
417 |
max_depth |
6 |
num_leaves |
31 |
learning_rate |
0.0543 |
subsample |
0.9369 |
colsample_bytree |
0.6407 |
min_child_samples |
15 |
reg_alpha |
0.8059 |
reg_lambda |
0.0557 |
Evaluation Results
Cross-Validation (5-fold Stratified)
| Model | Mean F1 | Std F1 |
|---|---|---|
| LightGBM | 0.8749 | 0.0321 |
| XGBoost | 0.8714 | 0.0109 |
Threshold-Tuned (Out-of-Fold)
| Metric | Value |
|---|---|
| Threshold | 0.36 |
| F1 (OOF) | 0.8769 |
Top 10 Features (LightGBM importance β split count)
| Rank | Feature | Importance |
|---|---|---|
| 1 | sodium_mg_kg | 266 |
| 2 | copper_mg_kg | 183 |
| 3 | moisture | 153 |
| 4 | molybdenum_mg_kg | 150 |
| 5 | zinc_mg_kg | 131 |
| 6 | cropland_pct | 122 |
| 7 | magnesium_mg_kg | 118 |
| 8 | phosphorus_mg_kg | 109 |
| 9 | cn_ratio | 100 |
| 10 | manganese_mg_kg | 95 |
How to Reproduce
# Clone the model repository
git clone https://huggingface.co/food-ai-nexus/soil-listeria-baseline
cd soil-listeria-baseline
# Install dependencies
pip install -r requirements.txt
# Run training (requires the dataset repo as a sibling directory)
python train.py
The training script expects the dataset at
../soil-listeria-us-land/data/{train,test}-00000-of-00001.parquet. You can
obtain it from:
git clone https://huggingface.co/datasets/food-ai-nexus/soil-listeria-us-land
Inference
import joblib
import numpy as np
model = joblib.load("model/model.joblib")
THRESHOLD = 0.36
# X_new: pandas DataFrame with the same feature columns as training data
probas = model.predict_proba(X_new)[:, 1]
predictions = (probas >= THRESHOLD).astype(int)
Citation
If you use this model or dataset, please cite the original study:
Liao, J., Wiedmann, M., & Bhatt, V. (2021). Nationwide genomic atlas of soil-associated Listeria reveals effects of selection and population ecology on pangenome evolution. Nature Microbiology, 6, 1021--1030.
@article{liao2021nationwide,
title={Nationwide genomic atlas of soil-associated {Listeria} reveals effects
of selection and population ecology on pangenome evolution},
author={Liao, Jingqiu and Wiedmann, Martin and Bhatt, Vipul},
journal={Nature Microbiology},
volume={6},
pages={1021--1030},
year={2021},
publisher={Nature Publishing Group}
}
- Downloads last month
- -
Dataset used to train food-ai-nexus/soil-listeria-baseline
Collection including food-ai-nexus/soil-listeria-baseline
Evaluation results
- F1 (5-fold CV) on soil-listeria-us-landself-reported0.875