File size: 2,583 Bytes
2788dfa
d5697e0
 
 
 
 
 
 
 
 
 
 
2788dfa
d5697e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---

library_name: pytorch
tags:
- graph-neural-network
- knowledge-graph
- agricultural-ai
- crop-recommendation
- gcn
- graph-embeddings
license: mit
datasets:
- ugandan-agricultural-data
---


# Agricultural AI Graph Embedding Models

Graph neural network models trained on Ugandan agricultural knowledge graph for crop recommendation.

## Model Overview

This repository contains multiple graph embedding models trained on an agricultural knowledge graph with 175,318 triples representing crop-soil-climate relationships.

## Models Included

### Best Model: GCN (Graph Convolutional Network)
- **File**: `best_model.pth`
- **Accuracy**: 87.28%
- **F1-Score**: 85.71%
- **ROC-AUC**: 96.90%
- **Embedding Dimension**: 100
- **Entities**: 2,513
- **Relations**: 15

### Individual Models
1. **GCN Model** (`gcn_model.pth`) - Best performing
2. **TransE Model** (`transe_model.pth`) - Translation-based
3. **DistMult Model** (`distmult_model.pth`) - Bilinear
4. **ComplEx Model** (`complex_model.pth`) - Complex embeddings
5. **GraphSAGE Model** (`graphsage_model.pth`) - Sampling-based

## Model Metadata

The `model_metadata.json` file contains:
- Entity to ID mappings (2,513 entities)
- Relation to ID mappings (15 relations)
- ID to entity mappings
- Model configuration parameters

## Usage

```python

import torch

from huggingface_hub import hf_hub_download



# Download model

model_path = hf_hub_download(

    repo_id="Awongo/soil-crop-recommendation-model",

    filename="best_model.pth"

)



# Download metadata

metadata_path = hf_hub_download(

    repo_id="Awongo/soil-crop-recommendation-model",

    filename="model_metadata.json"

)



# Load model (pseudo-code - adjust to your model architecture)

# model = GCNModel(num_entities=2513, num_relations=15, embedding_dim=100)

# model.load_state_dict(torch.load(model_path, map_location='cpu'))

# model.eval()

```

## Training Data

- **Knowledge Graph**: 175,318 triples
- **Dataset**: Ugandan agricultural data
- **Literature**: 52 research papers
- **Crops**: 8 major crops (maize, rice, beans, cassava, sweet potato, banana, coffee, cotton)

## Application

Used in production for agricultural crop recommendations based on:
- Soil properties (pH, organic matter, nutrients)
- Climate conditions (temperature, rainfall)
- Knowledge graph embeddings

## Citation

```bibtex

@misc{agricultural-ai-graph-models,

  title={Agricultural AI Graph Embedding Models for Crop Recommendation},

  year={2025},

  publisher={Hugging Face}

}

```