Supply Chain
Collection
Datasets and models supporting food supply chain risk analysis β spanning preharvest environments, dairy farms, processing facilities. β’ 8 items β’ Updated
A Random Forest classifier for predicting milk spoilage type based on microbial count data.
This model classifies milk samples into three spoilage categories based on Standard Plate Count (SPC) and Total Gram-Negative (TGN) bacterial counts measured at days 7, 14, and 21 of shelf life.
| Feature | Description |
|---|---|
| SPC_D7 | Standard Plate Count at Day 7 (log CFU/mL) |
| SPC_D14 | Standard Plate Count at Day 14 (log CFU/mL) |
| SPC_D21 | Standard Plate Count at Day 21 (log CFU/mL) |
| TGN_D7 | Total Gram-Negative count at Day 7 (log CFU/mL) |
| TGN_D14 | Total Gram-Negative count at Day 14 (log CFU/mL) |
| TGN_D21 | Total Gram-Negative count at Day 21 (log CFU/mL) |
import requests
API_URL = "https://api-inference.huggingface.co/models/chenhaoq87/MilkSpoilageClassifier"
headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}
# Input: [SPC_D7, SPC_D14, SPC_D21, TGN_D7, TGN_D14, TGN_D21]
payload = {"inputs": [[4.5, 5.2, 6.1, 3.2, 4.0, 4.8]]}
response = requests.post(API_URL, headers=headers, json=payload)
print(response.json())
import joblib
import numpy as np
# Load the model
model = joblib.load("model/model.joblib")
# Prepare input features
# [SPC_D7, SPC_D14, SPC_D21, TGN_D7, TGN_D14, TGN_D21]
features = np.array([[4.5, 5.2, 6.1, 3.2, 4.0, 4.8]])
# Make prediction
prediction = model.predict(features)
probabilities = model.predict_proba(features)
print(f"Predicted class: {prediction[0]}")
print(f"Class probabilities: {dict(zip(model.classes_, probabilities[0]))}")
If you use this model, please cite the original research on milk spoilage classification.
MilkSpoilageClassifier/
βββ apps/
β βββ fastapi/ # REST API application
β βββ gradio/ # Interactive web interface
β βββ huggingface/ # HF Inference handler
βββ data/ # Training and test datasets
βββ docs/ # Documentation files
βββ model/ # Trained model artifacts
βββ notebooks/ # Jupyter notebooks for analysis
βββ scripts/ # Utility scripts
βββ README.md # This file
See individual README files in each directory for more details.
python scripts/prepare_model.py
cd apps/gradio
pip install -r requirements.txt
python app.py
cd apps/fastapi
pip install -r requirements.txt
python app.py
python scripts/upload_to_hf.py
MIT License