S
All projects
Machine Learning2020·B.Tech Capstone (Team of 4)

Crop Yield Prediction

Regression Analysis for Agricultural Yield

An academic ML capstone that predicts agricultural crop yield from environmental and historical production factors using regression analysis and gradient descent — helping identify the most suitable, highest-yielding crop for a region.

Linear / Polynomial / SVR regression Gradient descent Feature normalization Correlation analysis Yield forecasting Python + R Data visualization

0.33

Area–production corr.

lm + glm

Models

6:2:2

Data split

Sugarcane

Top-yield crop

Business challenge

Indian agriculture often relies on guesswork for which crop to cultivate, yet yield depends on many factors — soil fertility, moisture, temperature, rainfall and historical production. Farmers lack a data-driven way to choose the crop that maximizes yield for their conditions.

What I built

Built a regression-based prediction pipeline in Python — preprocessing and feature normalization, gradient-descent-optimized linear regression (with polynomial and SVR comparisons), evaluated across train/validation/test splits — over Andhra Pradesh crop production data (area, yield and production by crop, district and year). Used R's lm/glm models to quantify the area–production relationship and surface the highest-yield crops and districts.

Why it matters

Agriculture contributes roughly 18% of India's GDP and employs about half its workforce, so poor crop choices and low yields carry real economic and human cost. A predictive model gives farmers and planners a data-driven decision aid.

How it's designed

01Data
Crop DatasetArea / Yield / Production
02Preprocess
NormalizationImputation
03Model
Gradient DescentLinear / Poly / SVR
04Evaluate
ResidualsCorrelationLeverage

Interface

Screenshot placeholder — drop product UI here

How the intelligence flows

  1. 01Ingest — crop production dataset (area, yield, production by crop / district / year).
  2. 02Preprocess — noise reduction, imputation and feature normalization.
  3. 03Train — gradient-descent linear regression with a 6:2:2 train/validation/test split.
  4. 04Tune — learning-rate selection via cost-vs-iteration convergence plots.
  5. 05Evaluate — residual analysis, correlation and leverage diagnostics.
  6. 06Interpret — rank the highest-yield crops and districts.

How data is modeled

  • Structured crop dataset: state, district, crop, season, area (hectares), production (tonnes), year.
  • Derived, normalized feature tables used as regression inputs.
  • Model outputs: predicted production plus correlation and leverage diagnostics.

Technologies

PythonNumPyscikit-learnPandasMatplotlibR (lm/glm)

Key features

  • Linear, polynomial and support-vector regression comparison.
  • Gradient-descent optimization with convergence monitoring.
  • Feature normalization and train/validation/test evaluation.
  • Correlation and leverage diagnostics.
  • Highest-yield crop and district identification.

Challenges & trade-offs

Choosing the learning rate

Too large and gradient descent diverges; too small and it crawls. The rate was tuned by inspecting cost-vs-iteration convergence plots.

Feature scaling

Area and production span very different ranges, so features were normalized to keep the regression well-conditioned.

Code snippet

Gradient-descent linear regressionpython
def gradient_descent(X, y, alpha=0.1, iters=400):
    m, n = X.shape
    theta = np.zeros(n)
    for _ in range(iters):
        error = X @ theta - y
        theta -= (alpha / m) * (X.T @ error)   # simultaneous update
    return theta

# normalize features, then fit
Xn = (X - X.mean(0)) / X.std(0)
theta = gradient_descent(Xn, production)

How it ships

  • Delivered as an academic project with Python notebooks and R analysis.

Security

  • Uses public agricultural datasets only.

Scalability

  • Vectorized NumPy computation.
  • Extensible to additional crops, districts and states.

Future roadmap

Extend to more crops and states.
Incorporate live weather and soil data.
Deploy as a farmer-facing recommendation tool.

Lessons learned

Feature scaling and learning-rate choice mattered more than model complexity.
Simple, interpretable regression can still deliver real agronomic insight.