A Machine Learning model that maximizes profit based on given environmental parameters, by recommending the suitable crop(s)
# Precision Agriculture Investment Engine
## 1. Project Overview
We built this system around a trained XGBoost Classifier to analyze soil and climate data. Rather than simply predicting a crop, we provide a **Risk-Adjusted Suitability Analysis** to help us and our investors decide where to allocate capital effectively.
---
## 2. File Structure
| File | Description |
|------|-------------|
| `crop_investment_system.pkl` | Our serialized "Master Bundle" — contains the Model, Scalers, and Math |
| `investment_engine.py` | The Python script we use to run the analysis |
| `requirements.txt` | Our list of dependencies: `xgboost`, `scikit-learn`, `pandas`, `numpy`, `joblib`, `fpdf`, `seaborn`, `matplotlib` |
---
## 3. How to Run the Analysis
To use the model in a real-world scenario, we follow these steps in our Python environment:
```python
import joblib
from investment_engine import production_inference, create_pdf_report
# 1. Load the Master System
# This file name must match exactly:
system_file = 'crop_investment_system.pkl'
system = joblib.load(system_file)
# 2. Define the Investor's Soil Data
raw_data = {
'N': 90, 'P': 42, 'K': 43,
'Temp': 20.8, 'Hum': 82.0, 'pH': 6.5, 'Rain': 202.9
}
# 3. Choose Risk Profile: 'conservative' (50%), 'balanced' (30%), or 'aggressive' (10%)
risk = 'balanced'
# 4. Run the Engine
recommendations = production_inference(
raw_data['N'], raw_data['P'], raw_data['K'],
raw_data['Temp'], raw_data['Hum'], raw_data['pH'], raw_data['Rain'],
risk_level=risk
)
# 5. Generate the Official PDF Report
if recommendations is not None:
create_pdf_report(raw_data, recommendations, risk)
```
---
## 4. Understanding the Scenarios
We designed the engine to protect our investors by categorizing results into three clear outcomes:
| Scenario | Condition | Interpretation |
|----------|-----------|----------------|
| **Scenario A — High Confidence** | A single crop dominates the environmental profile | Lowest risk; we recommend full allocation |
| …