Skip to content
Vibhrav Jha.Let’s talk

Lake Mendota Ice Regression

Two optimization paths through one regression objective

My contributionClosed-form and gradient-descent regression implementations.

FieldML & AI / Data Engineering

View repository

Academic foundations exercise

Two routes to the same regression objective — explanatory architecture diagram

The work
behind the interface.

Compared closed-form and gradient-descent solutions to the same ice-cover regression problem, implementing both directly in NumPy.

  • Python
  • NumPy
  • linear regression

The result

A compact implementation for examining fitted relationships and optimization behavior.

The problem

Implemented regression with NumPy using both an analytical solution and gradient descent.

A decision worth examining

Compare the same objective through closed-form and iterative optimization.

Read the README.

View original README
READMEArchitecture, setup and usage

Lake Mendota Ice Cover: Linear Regression from Scratch

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.

Frozen days per year

Method

  1. Features: years are min-max normalized to [0, 1], and a bias column is added. The design matrix is X = [x_norm, 1].
  2. Closed form: w = (XᵀX)⁻¹ Xᵀy.
  3. Gradient descent: minimizes the mean squared error, L = (1/2n)·Σ(Xw − y)², with gradient (1/n)·Xᵀ(Xw − y). The loss curve below shows it converging to the closed-form solution.
  4. Interpretation: the sign of the slope gives the direction of the trend, and solving w·x + b = 0 gives the year the fitted line reaches zero ice days.

Gradient descent loss

Results

With learning rate 0.4 and 500 iterations:

QuantityValue
Slope signnegative: 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.

Usage

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

Bayesian Language Detection

  1. Aranyaka wildlife-image application interface

    Fullstack

    Aranyaka

  2. DermaNet hackathon prototype showing classification output and a generated explanation

    ML & AI

    DermaNet

  3. AI-generated concept illustration of source documents connected to retrieved evidence and an answer

    ML & AI

    Private-Data RAG

  4. Before It Breaks dashboard separating real weather from synthetic equipment telemetry and estimated costs

    ML & AI

    Before It Breaks

  5. Architecture diagram of simulated stock records flowing through Kafka to HDFS

    Distributed Systems

    Stock Streaming Engine

  6. Vyaya dashboard with clearly labeled synthetic demonstration data

    Fullstack

    Vyaya

  7. Study assistant interface with retrieved source context

    ML & AI

    Fine-Tuning vs. RAG

  8. Architecture diagram of NOAA data, a Cassandra cluster and a query service

    Distributed Systems

    Distributed Weather Data System

  9. Distributed Property Lookup Service project image

    Distributed Systems

    Distributed Property Lookup Service

  10. Architecture diagram connecting MySQL, a gRPC service and HDFS storage

    Distributed Systems

    HDFS & SQL Pipeline

  11. Architecture diagram of Spark processing, SQL and analysis

    Distributed Systems

    Spark Analytics

  12. Multi-Source ELT Pipeline project image

    Data Engineering

    Multi-Source ELT Pipeline

  13. Wisconsin schools in their geographic context — explanatory architecture diagram

    Data Engineering

    GCP Geospatial Pipeline

  14. Chinook Music Store SQL Analytics project image

    Data Engineering

    Chinook Music Store SQL Analytics

  15. Yelp Geospatial Analytics project image

    Data Engineering

    Yelp Geospatial Analytics

  16. E-Commerce Semantic Search Engine project image

    Data Engineering

    E-Commerce Semantic Search Engine

  17. Retail Sales Forecasting project image

    ML & AI

    Retail Sales Forecasting

  18. Making tool dependencies inspectable — explanatory architecture diagram

    ML & AI

    AI Agent Tool Dependency Graph

  19. From public records to operational questions — explanatory architecture diagram

    Data Engineering

    Palantir Foundry and AIP Build Challenge

  20. StudyFlow study-session dashboard

    Fullstack

    StudyFlow

  21. Habit Command Center planning dashboard

    Fullstack

    Habit Command Center

  22. Interfaces across web and mobile — explanatory architecture diagram

    Fullstack

    React Web & Mobile

  23. Startup Scout project image

    Fullstack

    Startup Scout

  24. Inventory-Based Recipe Planner project image

    Fullstack

    Inventory-Based Recipe Planner

  25. Concurrent Word Count and Performance Benchmarking project image

    Data Engineering

    Concurrent Word Count

  26. Data structures matched to their assumptions — explanatory architecture diagram

    Computing Foundations

    Algorithm Design

  27. Campus Navigator project image

    Fullstack

    Campus Navigator

  28. i-Songly: Song Management Engine project image

    Fullstack

    i-Songly

  29. An experiment that can resume — explanatory architecture diagram

    ML & AI

    CIFAR-100 with LeNet

  30. Fashion-MNIST Neural Network Classifier project image

    ML & AI

    Fashion-MNIST Classifier

  31. PCA Eigenfaces and Image Reconstruction project image

    ML & AI

    PCA Eigenfaces

  32. Two routes to the same regression objective — explanatory architecture diagram

    ML & AIViewing

    Lake Mendota Ice Regression

  33. Bayesian Language Detection project image

    ML & AI

    Bayesian Language Detection

  34. Explanatory diagram of the video-fingerprint benchmark: 25 sources, 75 transformed variants and 1,875 comparisons.

    ML & AI

    Video-Fingerprint Benchmark

All projects