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.
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
Interface
How the intelligence flows
- 01Ingest — crop production dataset (area, yield, production by crop / district / year).
- 02Preprocess — noise reduction, imputation and feature normalization.
- 03Train — gradient-descent linear regression with a 6:2:2 train/validation/test split.
- 04Tune — learning-rate selection via cost-vs-iteration convergence plots.
- 05Evaluate — residual analysis, correlation and leverage diagnostics.
- 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
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
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.