File size: 2,805 Bytes
29ba864
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
language:
- en
metrics:
- accuracy
pipeline_tag: tabular-classification
tags:
- recommendation
- classification
- crop-recommendation
---

# Model Card for Infinitode/CRM-OPEN-ARC

Repository: https://github.com/Infinitode/OPEN-ARC/

## Model Description

OPEN-ARC-CR is a straightforward XGBClassifier model developed as part of Infinitode's OPEN-ARC initiative. It was trained to recommend crops that will thrive under specific environmental constraints and variables.

**Architecture**:

- **XGBClassifier**: Default XGB hyperparams
- **Framework**: XGBoost
- **Training Setup**: Trained with `use_label_encoder=False` and used `eval_metric='mlogloss'`.

## Uses

- Identifying appropriate crops for specific environmental conditions.
- Enhancing crop production by determining optimal environments for growth.
- Investigating factors that influence crop yields and those that limit productivity.

## Limitations

- Potentially generates implausible or inappropriate recommendations when influenced by extreme outlier values.
- May provide inaccurate recommendations; exercise caution when relying on these outputs.

## Training Data

- Dataset: Crop Recommendation Dataset from Kaggle.
- Source URL: https://www.kaggle.com/datasets/varshitanalluri/crop-recommendation-dataset
- Content: Soil properties, rainfall patterns, and other agricultural metrics, coupled with the recommended crop.
- Size: 2200 entries of crop recommendations.
- Preprocessing: Label-encoded target `Crop` using `sklearn's LabelEncoder`.

## Training Procedure

- Metrics: accuracy
- Train/Testing Split: 80% train, 20% testing.

## Evaluation Results

| Metric | Value |
| ------ | ----- |
| Train Accuracy | not used |
| Testing Accuracy | 98.6% |

## How to Use

```python
def test_random_samples(model, X_test, y_test, le, n_samples=6):
    # Select 6 random indices
    random_indices = random.sample(range(X_test.shape[0]), n_samples)
    
    # Extract the random samples
    X_sample = X_test.iloc[random_indices, :]
    y_true_sample = y_test.iloc[random_indices]
    
    # Predict crop recommendations
    y_pred_sample = model.predict(X_sample)
    
    # Decode the predictions and ground truth back to crop names
    crops_pred = le.inverse_transform(y_pred_sample)
    crops_true = le.inverse_transform(y_true_sample)
    
    # Display the results
    for i in range(n_samples):
        print(f"Sample {i+1}:")
        print(f"Features: \n{X_sample.iloc[i]}")
        print(f"Predicted Crop: {crops_pred[i]}")
        print(f"Ground Truth: {crops_true[i]}")
        print("-" * 30)

# Test the function with random samples
test_random_samples(model, X_test, y_test, le)
```

## Contact

For questions or issues, open a GitHub issue or reach out at https://infinitode.netlify.app/forms/contact.