Model package for loading pretrained soil fertility and fertilizer recommendation models for Morocco.
Project description
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
- packaged
.joblibmodel files undersrc/turba_models/models/ - the training notebook used to produce the current results under
notebooks/ - exported benchmark summaries under
reports/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file turba_models-0.1.0.tar.gz.
File metadata
- Download URL: turba_models-0.1.0.tar.gz
- Upload date:
- Size: 4.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ccbdb390803f03c56ec66ead73089fd1e9136c76eab85935c842895c9ec3e89
|
|
| MD5 |
d9a644c8ac31ace0b621c344567c2e83
|
|
| BLAKE2b-256 |
e23e9a79a6063b352fce0d5fcb2e7c2758c1ad68f514d71dc69adaf17f3c040a
|
File details
Details for the file turba_models-0.1.0-py3-none-any.whl.
File metadata
- Download URL: turba_models-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c0f5e17c0ca2c2171bc91137851f568787bb37e4aaed92a67aadf38b6ef69f7
|
|
| MD5 |
8a948d85eb824fe1339b57ef2af288c9
|
|
| BLAKE2b-256 |
3575cafe514685fad4288fb8540f37f7b876ae794cbe6baab73eae6431ab3094
|