A hands-on walkthrough of building a baseline item-item recommender system using iterative matrix factorization in PyTorch, trained on Amazon product data. Covers data acquisition from JSON, parsing product-pair relationships, assigning weighted scores (bought together, also bought, also viewed), generating negative samples efficiently, and training with both binary and continuous labels. Discusses L2 regularization, cosine annealing, adding product biases, and evaluating with ROC-AUC and precision-recall curves. Key insight: adding bias improves precision-recall curve shape even when AUC-ROC drops, and plotting curves matters more than relying solely on numeric metrics. Achieves ~0.8 AUC-ROC on electronics data running on a 16GB laptop.
Table of contents
OverviewData AcquisitionParsing jsonGetting product relationshipsConverting relationships into a single scoreTrain-validation splitCollaborating filtering (how it is commonly known)Implementation 1: Matrix Factorization (iteratively pair by pair)ResultsImplementation 2: Matrix Factorization with BiasKey takeawaysWhat’s next?References1 Impression