Role: Solo Builder : end-to-end architecture, ML pipeline, XAI integration, full-stack deployment

Indian farmers lose billions every year growing the wrong crop in the wrong soil, not because they're careless, but because traditional knowledge can't account for real-time soil chemistry and live weather patterns. AgriVerse is a deployed, full-stack explainable AI system that takes a farmer's soil parameters (N, P, K, pH) and live location, fetches real-time weather data, and recommends the top 3 crops with probability scores, SHAP-based explanations, counterfactual alternatives, and a trust score. Built on XGBoost with 99.80% classification accuracy across 22 crop types.
India produces more mangoes than any other country on Earth, yet crop failures from poor planning cost the agricultural sector billions every year. The core problem isn't lack of technology. It's that existing ML crop recommendation systems are black boxes: they tell a farmer "grow rice" but offer no explanation, no alternative, and no guidance on what to do if rice isn't viable. Farmers without formal technical training have no reason to trust a system they can't understand. AgriVerse was built to fix exactly this, a system that doesn't just predict, but explains, justifies, and guides.
Most crop recommendation systems are technically impressive and practically useless for the people they're meant to serve. A Random Forest model that says "grow chickpea" with 94% accuracy is worthless to a farmer who doesn't know why chickpea, what happens if the soil pH is slightly off, or what to grow instead if chickpea isn't viable this season. AgriVerse was built around one principle: transparency is not optional in systems that affect people's livelihoods.
A farmer enters their soil's N, P, K, and pH values — the four parameters available from any basic soil test — and shares their location. The system does the rest.
| Step | What Happens |
|---|---|
| Weather fetch | Open-Meteo API retrieves live temperature, humidity, and rainfall for the exact location |
| Prediction | All 7 variables passed to an XGBoost classifier trained on 2,200 instances across 22 crop types |
| Output | Probability scores for all 22 crops simultaneously — top 3 surfaced to the user |
That's where most systems stop. AgriVerse is just getting started.
Every recommendation is accompanied by a SHAP waterfall chart showing exactly which soil and weather variables pushed the model toward or away from each crop. This is mathematically grounded in cooperative game theory — each feature receives its fair attribution of the prediction.
For each of the top 3 recommendations, a dedicated SHAP bar chart shows why that specific crop was chosen for this specific farm. A farmer can see, for example, that high rainfall strongly supports a rice recommendation while the soil's potassium level is slightly working against it.
A precomputed global feature importance chart shows which variables matter most across the entire model — useful for agricultural researchers and extension workers understanding systemic patterns.
Not all recommendations are equally confident. AgriVerse introduces a Trust Score — derived from the probability margin between the top crop and its competitors, penalised dynamically if any input data is missing or if the weather API fails.
| Trust Level | Meaning |
|---|---|
| High | Strong probability margin, all inputs present |
| Medium | Moderate margin or minor data gaps |
| Low | Narrow margin, missing inputs, or API fallback |
Farmers and advisors know exactly how much weight to give each recommendation.
If the top recommended crop isn't viable — wrong market, wrong season, wrong logistics — the counterfactual engine finds the next-best crop that could become viable with minimal soil adjustments.
It computes Euclidean distance between the user's current N, P, K, pH profile and the centroid profiles of all other crop categories in the training data. Weather variables are deliberately excluded — a farmer can't change the weather. Only soil-amendable variables count.
The result is a concrete, actionable suggestion like:
"Rice can also be grown — decrease Phosphorus from 50 to 47.58 and decrease Potassium from 43 to 39.87."
That's not a prediction. That's a farming plan.
Every recommendation includes a plain-language report that translates the SHAP analysis into readable guidance — top contributing factors, hindering factors, and prescriptive recommendations comparing current soil values to optimal agronomic ranges. When data is incomplete, the system flags assumptions explicitly.
XGBoost trained on 2,200 instances, 22 crop classes, 7 features. 5-fold cross-validation with grid search hyperparameter tuning.
| Metric | Result |
|---|---|
| Overall Accuracy | 99.80% |
| Perfect F1 (1.00) | 18 of 22 crop classes |
| Remaining 4 classes | F1 scores of 0.98–0.99 |
A novel dropout simulation strategy was used during training — randomly masking input features to simulate incomplete real-world data (missing soil tests, sensor failures). This makes the model robust to partial inputs, a critical requirement for smallholder agriculture in India where complete soil data is often unavailable.
| Layer | Technology |
|---|---|
| Frontend | ReactJS — user input and dynamic visualisation via Chart.js |
| Backend | Express.js API gateway — orchestrates calls to Python ML pipeline via shell execution |
| ML Pipeline | Python — XGBoost inference, SHAP computation, trust scoring, counterfactual analysis |
| Output Format | Structured JSON with four tiers: predictive, interpretative, actionable, narrative |
| Weather | Open-Meteo API (live, location-specific) |
The ML model is fully decoupled from the API and frontend — it can be updated independently without touching either layer.
Deployed production system serving real crop recommendations for Indian farmers, 99.80% accuracy across 22 crops, with explainability that tells you not just what to grow but why and how to adjust your soil to grow something better.