Skip to main content
Agriculture· 20-page report· 8 figures

India Crop Yield Prediction

Build Random Forest models for crop yield and soil fertility prediction across 33 Indian states with 71% test R².

What this research found

Two Random Forest models were built on Indian agricultural data: one predicting crop yield from 237,932 district-season-crop records spanning 1997 to 2015, the other classifying soil samples as fertile or not from 16 measured properties. Using only state, season, crop and year, the yield model explains 71.0% of variance on held-out data at an RMSE of 14.46 tonnes per hectare, and analysis of variance confirms that yields differ significantly across both seasons and states.

  • The yield regressor reached a test R² of 0.7103 with an RMSE of 14.4630 on 47,587 held-out records, against a training R² of 0.9179. The analysis flags that gap as overfitting.
  • Year dominates the yield model at 0.4853 of feature importance, ahead of state at 0.3382 and crop at 0.1496. Season contributes almost nothing, at 0.0269.
  • Yields differ significantly across the six seasons (F = 1264.82, with a p-value below floating-point resolution) and across the top five producing states (F = 112.28, p = 1.0985e-95). Tamil Nadu leads on mean yield at 12.26 tonnes per hectare, followed by Kerala at 8.62 and Assam at 8.57, against a national mean of 5.01.
  • The soil fertility classifier scored 100% accuracy with perfect precision and recall on both classes — but on just 20 test samples drawn from a 100-record dataset.
  • Texture outweighs nutrients in predicting the fertility label: clay content carries 0.2380 of importance and cation exchange capacity 0.1487, ahead of every macronutrient, with phosphorus highest at 0.0540. Nitrogen and organic carbon move together closely (r = 0.875), while pH and phosphorus are essentially unrelated (r = -0.104).

How it was done

A district-wise crop production dataset compiled from Government of India agricultural statistics supplied 246,091 records covering 105 crops across 33 states from 1997 to 2015, of which 237,932 survived cleaning, with yield derived from production and cultivated area. A Random Forest regressor was trained on an 80/20 split using state, season, crop and year. A separate 100-sample soil dataset carrying 16 properties — pH, electrical conductivity, organic carbon and matter, macro- and micronutrients, sand, silt and clay fractions, calcium carbonate and cation exchange capacity — trained a Random Forest classifier for binary fertility. One-way ANOVA then tested yield differences across seasons and across the five largest producing states, and the results were compiled into an illustrated report.

Data sources

  • District-wise crop production dataset compiled from Government of India agricultural statistics — 246,091 records, 105 crops, 33 states and union territories, 1997–2015
  • Soil fertility research dataset — 100 samples with 16 properties, aligned with the parameters of India's Soil Health Card scheme

Limitations

The yield model sees only state, season, crop and year, with no weather, irrigation, fertiliser or district-level detail, and its training-to-test gap points to overfitting. The perfect soil classification rests on 20 test samples from a 100-record dataset that carries no geographic identifiers, so it cannot be joined to the crop data or treated as generalisable.

Figures from this analysis

Confusion matrix heatmap for soil fertility classification (Fertile vs Non-Fertile)
Correlation heatmap of 10 soil nutrient parameters
Bar chart showing top 15 features for soil fertility classification model
Boxplots comparing N, P, K nutrients across Soil_Class and Texture_Class
Dual-axis bar chart showing total production vs mean yield for top 5 states
Histogram of crop yield distribution (linear and log scale)
Time series plot of average yield for top 5 crops (1997-2015)

Outputs produced

  • crop_production_district.csv

    District-wise crop production data for India (246,091 raw records)

  • soil_fertility_data.csv

    Soil fertility data with 16 soil health parameters (100 records)

  • 01_verify_datasets.py

    Python script to verify downloaded datasets and analyze structure

  • dataset_inventory.md

    Comprehensive inventory of acquired datasets with metadata, column descriptions, and data quality notes

  • 02_preprocess_data.py

    Data preprocessing pipeline: cleaning, standardization, yield calculation, and anomaly filtering

  • clean_crop_production.csv

    Cleaned crop production data with calculated Yield column (237,932 records)

  • clean_soil_data.csv

    Cleaned soil fertility data with Soil_Class and Texture_Class columns (100 records)

  • state_crop_yield_summary.csv

    Aggregated yield statistics by State and Crop (1,168 combinations)

How this research was produced

K-Dense Web planned and ran this agriculture investigation end to end — gathering the sources, carrying out the analysis, producing the figures, and drafting the report. The full session transcript, including every intermediate step, is available to view.

Share:
Agriculture

US Vineyard Location Analysis

Evaluate AVAs for Tempranillo/Cabernet Franc blend with $5M budget across terroir, climate, and business factors.

Agriculture

Arabidopsis Drought–Heat Accession Panel

Nominate 24 genetically, climatically, and ancestrally diverse Arabidopsis accessions from 1,135 lines for a factorial drought-by-heat common-garden experiment.

Agriculture

Satellite-Guided Crop Scouting in Iowa

Combine Sentinel-2 and USDA Cropland Data Layer imagery to rank 20 anomalous corn and soybean cells, pair controls, and design a nitrogen-by-water field trial.

Run this kind of analysis on your own question

Try K-Dense Web free and see how an AI co-scientist accelerates your research.