$ show amitshekhariitbhu/build-your-own-x-machine-learning
This repository is a comprehensive collection of educational tutorials that implement machine learning algorithms and applications entirely from scratch using only NumPy. It covers a vast range of topics including core ML algorithms (linear regression, SVM, K-means, PCA, etc.), neural networks (CNN, RNN, LSTM, GAN, transformer), computer vision (object detection, face recognition, OCR), natural language processing (sentiment analysis, chatbots, text summarization, BPE tokenizer), time series forecasting (ARIMA, LSTM, Prophet), recommendation systems, anomaly detection, and reinforcement learning. Each tutorial is a self-contained Python script that generates synthetic data with planted structure, trains a hand-coded model, and validates against naive baselines. The code is heavily commented and designed for teaching, not production. There are no real datasets, no external dependencies beyond NumPy, and no shared libraryβeach file is independent, leading to significant code duplication across tutorials. The repository serves as an excellent learning resource for understanding the inner workings of ML algorithms, but it is not suitable for direct reuse in production systems without substantial refactoring.
The LLM identified 3 files worth highlighting for reuse:
Implements a minimal PyTorch-like autograd system with Tensor, Function, and Module classes. Supports automatic differentiation for scalar and tensor operations, enabling gradient-based optimization. Demonstrates a clean, modular design that could be extracted as a lightweight educational autograd library.
Builds a transformer-based language model from scratch, including multi-head self-attention, positional encoding, feed-forward layers, and layer normalization. The implementation is self-contained and demonstrates the core transformer architecture in about 300 lines of NumPy code, making it a valuable reference for understanding transformers.
Implements Byte-Pair Encoding (BPE) tokenization from scratch, including vocabulary learning from a corpus and encoding/decoding functions. The code is clean, well-documented, and can be easily adapted for other tokenization tasks or integrated into NLP pipelines.