Building a Neural Network from Scratch: the Math and the Code

Introduction When I took Machine Learning in College, I never felt that online resources described the mathematical foundations to my tastes. To try and fix this, in this post I’ll explore the mathematical foundations underlying neural networks and walk through my from-scratch implementation for binary classification on the moons dataset. We’ll dive deep into the calculus, linear algebra, and optimization theory that makes these models work, culminating in a network that achieves 99.6% accuracy on the moons dataset. ...

03 May 2025 · 7 min · 1286 words

Building and Optimizing LSTM Networks for Sentiment Analysis

Introduction Recently, I’ve been tinkering around with training different AI models. Specifically, different types of networks. Long Short-Term Memory (LSTM) are good at natural language processing tasks, particularly sentiment analysis. In this demonstration, I’m going to build an LSTM-based sentiment classifier using TensorFlow and the IMDB movie reviews dataset. Then, I will compare different optimizers and learning rates to understand their impact on model performance. The Problem: Movie Review Sentiment Analysis The IMDB dataset contains 50,000 movie reviews labeled as positive or negative, making it perfect for binary sentiment classification. Our goal is to build an LSTM network that can accurately predict whether a review expresses positive or negative sentiment. ...

05 Apr 2025 · 4 min · 640 words

Building Logistic Regression from Scratch: A Complete Python Implementation

Introduction Understanding machine learning algorithms at their core is crucial for any data scientist. In this comprehensive tutorial, we’ll build logistic regression entirely from scratch using Python and NumPy. No black-box libraries, just the math implemented in code. We’ll use everything from the sigmoid function and cross-entropy loss to gradient descent optimization. Finally, we’ll test our implementation on the classic “moons” dataset to validate our approach. The Mathematical Foundation Logistic regression transforms linear combinations of features into probabilities using the sigmoid function: ...

05 Mar 2025 · 4 min · 737 words