Upload folder using huggingface_hub
Browse files- README.md +93 -1
- best_model.pth +3 -0
- best_model_info.json +14 -0
- complex_model.pth +3 -0
- distmult_model.pth +3 -0
- gcn_model.pth +3 -0
- graphsage_model.pth +3 -0
- model_metadata.json +0 -0
- transe_model.pth +3 -0
README.md
CHANGED
|
@@ -1,3 +1,95 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
library_name: pytorch
|
| 3 |
+
tags:
|
| 4 |
+
- graph-neural-network
|
| 5 |
+
- knowledge-graph
|
| 6 |
+
- agricultural-ai
|
| 7 |
+
- crop-recommendation
|
| 8 |
+
- gcn
|
| 9 |
+
- graph-embeddings
|
| 10 |
+
license: mit
|
| 11 |
+
datasets:
|
| 12 |
+
- ugandan-agricultural-data
|
| 13 |
---
|
| 14 |
+
|
| 15 |
+
# Agricultural AI Graph Embedding Models
|
| 16 |
+
|
| 17 |
+
Graph neural network models trained on Ugandan agricultural knowledge graph for crop recommendation.
|
| 18 |
+
|
| 19 |
+
## Model Overview
|
| 20 |
+
|
| 21 |
+
This repository contains multiple graph embedding models trained on an agricultural knowledge graph with 175,318 triples representing crop-soil-climate relationships.
|
| 22 |
+
|
| 23 |
+
## Models Included
|
| 24 |
+
|
| 25 |
+
### Best Model: GCN (Graph Convolutional Network)
|
| 26 |
+
- **File**: `best_model.pth`
|
| 27 |
+
- **Accuracy**: 87.28%
|
| 28 |
+
- **F1-Score**: 85.71%
|
| 29 |
+
- **ROC-AUC**: 96.90%
|
| 30 |
+
- **Embedding Dimension**: 100
|
| 31 |
+
- **Entities**: 2,513
|
| 32 |
+
- **Relations**: 15
|
| 33 |
+
|
| 34 |
+
### Individual Models
|
| 35 |
+
1. **GCN Model** (`gcn_model.pth`) - Best performing
|
| 36 |
+
2. **TransE Model** (`transe_model.pth`) - Translation-based
|
| 37 |
+
3. **DistMult Model** (`distmult_model.pth`) - Bilinear
|
| 38 |
+
4. **ComplEx Model** (`complex_model.pth`) - Complex embeddings
|
| 39 |
+
5. **GraphSAGE Model** (`graphsage_model.pth`) - Sampling-based
|
| 40 |
+
|
| 41 |
+
## Model Metadata
|
| 42 |
+
|
| 43 |
+
The `model_metadata.json` file contains:
|
| 44 |
+
- Entity to ID mappings (2,513 entities)
|
| 45 |
+
- Relation to ID mappings (15 relations)
|
| 46 |
+
- ID to entity mappings
|
| 47 |
+
- Model configuration parameters
|
| 48 |
+
|
| 49 |
+
## Usage
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
import torch
|
| 53 |
+
from huggingface_hub import hf_hub_download
|
| 54 |
+
|
| 55 |
+
# Download model
|
| 56 |
+
model_path = hf_hub_download(
|
| 57 |
+
repo_id="Awongo/soil-crop-recommendation-model",
|
| 58 |
+
filename="best_model.pth"
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
# Download metadata
|
| 62 |
+
metadata_path = hf_hub_download(
|
| 63 |
+
repo_id="Awongo/soil-crop-recommendation-model",
|
| 64 |
+
filename="model_metadata.json"
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
# Load model (pseudo-code - adjust to your model architecture)
|
| 68 |
+
# model = GCNModel(num_entities=2513, num_relations=15, embedding_dim=100)
|
| 69 |
+
# model.load_state_dict(torch.load(model_path, map_location='cpu'))
|
| 70 |
+
# model.eval()
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
## Training Data
|
| 74 |
+
|
| 75 |
+
- **Knowledge Graph**: 175,318 triples
|
| 76 |
+
- **Dataset**: Ugandan agricultural data
|
| 77 |
+
- **Literature**: 52 research papers
|
| 78 |
+
- **Crops**: 8 major crops (maize, rice, beans, cassava, sweet potato, banana, coffee, cotton)
|
| 79 |
+
|
| 80 |
+
## Application
|
| 81 |
+
|
| 82 |
+
Used in production for agricultural crop recommendations based on:
|
| 83 |
+
- Soil properties (pH, organic matter, nutrients)
|
| 84 |
+
- Climate conditions (temperature, rainfall)
|
| 85 |
+
- Knowledge graph embeddings
|
| 86 |
+
|
| 87 |
+
## Citation
|
| 88 |
+
|
| 89 |
+
```bibtex
|
| 90 |
+
@misc{agricultural-ai-graph-models,
|
| 91 |
+
title={Agricultural AI Graph Embedding Models for Crop Recommendation},
|
| 92 |
+
year={2025},
|
| 93 |
+
publisher={Hugging Face}
|
| 94 |
+
}
|
| 95 |
+
```
|
best_model.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5231df87148c0e3f25e6191392e6089af8c17679d3444f1eaaa13305dbdd19ef
|
| 3 |
+
size 1175417
|
best_model_info.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_name": "GCN",
|
| 3 |
+
"f1_score": 0.8571428571428571,
|
| 4 |
+
"all_metrics": {
|
| 5 |
+
"accuracy": 0.87275,
|
| 6 |
+
"precision": 0.9769673704414588,
|
| 7 |
+
"recall": 0.7635,
|
| 8 |
+
"f1_score": 0.8571428571428571,
|
| 9 |
+
"roc_auc": 0.9690023749999999,
|
| 10 |
+
"average_precision": 0.9708194406937413
|
| 11 |
+
},
|
| 12 |
+
"model_path": "/content/drive/MyDrive/Final/data/processed/trained_models/best_model.pth",
|
| 13 |
+
"metadata_path": "/content/drive/MyDrive/Final/data/processed/trained_models/model_metadata.json"
|
| 14 |
+
}
|
complex_model.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e8afdc422c174cc7f25eb5dfbb3cd3603f5d0599dd69ad8ed54cb1e892bf4b56
|
| 3 |
+
size 2024985
|
distmult_model.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6e192a9fdf394029f1b6efcfac1ae9ec05de8af31ae1072fcfd5c94d546394cb
|
| 3 |
+
size 1013213
|
gcn_model.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3eee81267cf9bc2cb98a96ebdf1308f740afcf6c69f4b7537efc6c72800b1f65
|
| 3 |
+
size 1175405
|
graphsage_model.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:25b629842d3038730298835a6bb76af5c0021aca6edc012de3e0d225033b767c
|
| 3 |
+
size 1255477
|
model_metadata.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
transe_model.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ba793e7be5bf89251dd1d023d76fbf18f662b6f4381ae1eff3eed89222cd6660
|
| 3 |
+
size 1013197
|