turba-models
Model package for loading pretrained soil fertility and fertilizer recommendation models for Morocco.
turba-models is the pretrained model package of the turba ecosystem. It provides a simple way to inspect the published model artifacts, load a model for a supported crop, and generate direct NPK recommendations.
Scope of this first release
This release publishes one direct recommendation model per available crop. The models were selected from the following candidates using a fixed deterministic 80/20 split and benchmarked with the same evaluation protocol:
- Extra Trees
- LightGBM
- CatBoost
- Random Forest
- XGBoost
- Linear Regression
- Ridge
- Elastic Net
- AdaBoost
The published models use only the following input features:
longitudelatitudesoil_phorganic_matter_pctavailable_p2o5available_k2o
Outputs are:
recommended_nrecommended_p2o5recommended_k2o
Installation
pip install turba-models
For compatibility with the packaged artifacts, use an environment with:
scikit-learn >= 1.6, < 1.7lightgbm >= 4, < 5xgboost >= 2, < 3
Quick start
import pandas as pd
import turba_models as tm
print(tm.list_models())
model = tm.load_model("Wheat (Rainfed)")
X = pd.DataFrame([
{
"longitude": -6.85,
"latitude": 33.97,
"soil_ph": 7.1,
"organic_matter_pct": 1.2,
"available_p2o5": 45.0,
"available_k2o": 180.0,
}
])
predictions = tm.predict_recommendation(model, X)
print(predictions)
Public API
from turba_models import (
list_models,
load_model,
predict_recommendation,
regression_report,
)
list_models()
Returns the published model entries and their metadata.
load_model(model_name)
Loads a packaged .joblib model. The function accepts either the crop name or the published model name.
predict_recommendation(model, X)
Runs inference and returns a DataFrame with:
recommended_nrecommended_p2o5recommended_k2o
regression_report(y_true, y_pred, target_names=None)
Returns a DataFrame with:
r2maemedaermsemapesmape
Published models in this package
- Barley (Rainfed) — LightGBM
- Maize (Grain) — XGBoost
- Maize (Silage) — XGBoost
- Wheat (Irrigated) — LightGBM
- Wheat (Rainfed) — LightGBM
Reproducibility
- Training and benchmark notebook reproduces the deterministic 80/20 benchmark across nine model families from the registered
turba-datasnapshot and generates the benchmark tables, selected-model summary, model registry, and serialized models. - Packaged model artifacts are under
src/turba_models/models/. - Benchmark outputs are under
reports/.
Metadata
Release files for turba-models 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| turba_models-0.1.1.tar.gz | 4.8 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| turba_models-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.7 MB
Release files / turba_models-0.1.1.tar.gz
| Download URL | turba_models-0.1.1.tar.gz |
|---|---|
| Size | 4.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98eda11960753fd98f9599d95bf79bbcb290eb377c8d10e5678f86edd2539cf0
|
|
BLAKE2b-256 checksum How to use checksums |
5135327e3648cd25af9c04c4ba875ad0a8764711560b37da1fc34cc1ac8ceff7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Release files / turba_models-0.1.1-py3-none-any.whl
| Download URL | turba_models-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.9 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bab788235e94dda00a983a5a2a071258d749654167a933d32434de61e4ea5451
|
|
BLAKE2b-256 checksum How to use checksums |
5ef69fcf5d93ab752ea685023954b5dc583a08fdfb8a521975faf7ad3bc36f38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|