Visualizations for Machine Learning

Quarto blogs and Streamlit apps that make optimization, information theory and probability concepts interactive.

2023-24 Prof. Nipun Batra, IIT Gandhinagar Vannsh Jani, Shreyans Jain, Viraj Vekaria (with Kishan Ved on some topics)
educationStreamlitoptimizationinformation-theoryvisualization

Problem. Machine learning algorithms are hard to understand from equations alone.
Approach. For each concept, write a Quarto blog post with from-scratch code and build a Streamlit app where the reader can change parameters and watch the algorithm run. Done as a CS299 project advised by Prof. Nipun Batra.
Result. More than a dozen live blogs and Streamlit apps covering optimization, information theory and probability. The gallery below has the highlights.

Overview

The project is part of Prof. Nipun Batra’s teaching effort. The CS299 report states the goal as bridging “the gap between machine learning intricacies and educational accessibility”. Each topic got a blog explaining the maths plus code, and, where useful, an app. The full write-up lives on the project notion page.

Method

Topics covered by the team include first-order optimizers (SGD, RMSProp, Adam), second-order methods (Newton, L-BFGS), Taylor series, constrained optimization with KKT conditions, computational graphs and autodiff, Huffman and Shannon-Fano coding, JPEG compression, SIREN-based audio and image compression, mutual information, noisy channel coding, Markov chains, Fisher information, change of variables and CORDIC.

A design lesson from the optimizer app: it first redrew the plot after every epoch, which was prohibitively slow. Storing the path in a list and plotting once at the end fixed speed, and animation was added later.

Stepping an optimizer with momentum on a contour plot
CORDIC app: the red vector converges on the target angle

Each card opens a live app or blog. All of them are listed on the project Notion page.

More apps

Topic App Authors
Fisher information fisher.streamlit.app Shreyans
Huffman coding huffman.streamlit.app Kishan and Shreyans
JPEG: coding the DCT matrix jpegcoding.streamlit.app Kishan and Shreyans
CORDIC algorithm cordic.streamlit.app Viraj and Shreyans
Change of variables (Jacobian) changeofvariables.streamlit.app Shreyans
Noisy channel coding noisychannelcoding.streamlit.app Vannsh

Results

Fisher information app
Huffman tree built step by step
Image reconstructed by a SIREN

One small measured result from the report: a from-scratch RMSProp contributed to the open-source wimpyML library reached 97.11% on MNIST, against 97.31% for torch.optim.RMSprop, with similar training time (115.7 s versus 113.3 s for 10 iterations).

My role

  • Optimizers. With Viraj, built the Streamlit app comparing SGD, Adam and RMSProp, plus the contour-plot momentum demo and the velocity app.
  • Information theory. With Kishan, the Huffman coding blog and app, and a Colab walk-through of the JPEG pipeline (YCbCr, chroma subsampling, DCT, quantization, Huffman).
  • Maths concepts. Blogs and apps on Fisher information and on change of variables with the Jacobian; with Viraj, the CORDIC app.