The result
A compact implementation for examining fitted relationships and optimization behavior.
Two optimization paths through one regression objective
Academic foundations exercise
Compared closed-form and gradient-descent solutions to the same ice-cover regression problem, implementing both directly in NumPy.
From the repository
Is Lake Mendota (Madison, WI) freezing for fewer days each winter? This project fits a linear trend to the lake's annual ice-cover record, which starts in 1855. It solves the same model two ways with NumPy only (no ML libraries): the closed-form normal equation and batch gradient descent. It then uses the trend to extrapolate.

X = [x_norm, 1].w = (XᵀX)⁻¹ Xᵀy.L = (1/2n)·Σ(Xw − y)², with gradient (1/n)·Xᵀ(Xw − y). The loss curve below shows it converging to the closed-form solution.w·x + b = 0 gives the year the fitted line reaches zero ice days.
With learning rate 0.4 and 500 iterations:
| Quantity | Value |
|---|---|
| Slope sign | negative: ice cover is shrinking over time |
| Predicted ice days in 2023 | ≈ 85.5 |
| Year the linear trend reaches 0 ice days | ≈ 2463 |
The last number is a naive linear extrapolation. Real ice cover depends on nonlinear climate dynamics, so read it as an illustration of the trend, not a forecast.
pip install -r requirements.txt
python ice_regression.py ice_data.csv 0.4 500 # <data> <learning_rate> <iterations>
The script prints the normalized design matrix, the closed-form weights, the gradient-descent weights (every 10 iterations), the 2023 prediction, and the zero-ice year. It also saves both plots.
Data: annual Lake Mendota ice-cover durations, as published by the Wisconsin State Climatology Office.
Date finished: March 3, 2025
Continue exploring · 34 projects

Fullstack

ML & AI

ML & AI

ML & AI
Distributed Systems

Fullstack

ML & AI
Distributed Systems

Distributed Systems
Distributed Systems
Distributed Systems

Data Engineering
Data Engineering

Data Engineering

Data Engineering

Data Engineering

ML & AI
ML & AI
Data Engineering

Fullstack

Fullstack
Fullstack

Fullstack

Fullstack
Data Engineering
Computing Foundations

Fullstack

Fullstack
ML & AI
ML & AI

ML & AI
ML & AIViewing
ML & AI
ML & AI