chenhaoq87's picture
Upload folder using huggingface_hub
b51e82d verified
|
Raw
History Blame Contribute Delete
5.24 kB
metadata
license: mit
library_name: sklearn
tags:
  - tabular-classification
  - food-safety
  - listeria
  - soil-microbiome
  - lightgbm
  - baseline
datasets:
  - food-ai-nexus/soil-listeria-us-land
metrics:
  - f1
  - accuracy
  - precision
  - recall
  - roc_auc
model-index:
  - name: soil-listeria-baseline
    results:
      - task:
          type: tabular-classification
          name: Binary Classification
        dataset:
          name: soil-listeria-us-land
          type: food-ai-nexus/soil-listeria-us-land
        metrics:
          - type: f1
            value: 0.8749
            name: F1 (5-fold CV)

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

  1. 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.
  2. Hyperparameter search — RandomizedSearchCV (100 iterations) over both XGBoost and LightGBM, scored by F1, using 5-fold stratified CV (random_state=42).

  3. Model selection — The model with the highest mean CV F1 is selected.

  4. 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.

  5. 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}
}