Case Details
Pixels to Predictions: A Machine Learning Application of K-Nearest Neighbors
Opening with the real-world operational bottleneck of a growing online secondhand fashion marketplace, this concept note uses a business scenario to explore the technical foundations of machine learning. The scenario of manually tagging thousands of user-uploaded images introduces supervised machine learning as a practical and scalable solution. Designed to demystify the black box of data science, the core of the note provides a step-by-step walkthrough of image classification using the K-Nearest Neighbors (KNN) algorithm.
Students are guided through the exact coding and mechanics, all explained in plain language, from how computers represent images as numerical pixel grids to how mathematical distance measures visual similarity and how KNN classifies the images. With accessible Python code snippets, students progress from basic image rendering to building, training, and evaluating predictive pipelines utilizing libraries like "scikit-learn" and "torchvision". Finally, an extension on data augmentation challenges students to think resourcefully like data analysts by manipulating existing data to improve predictive accuracy for visually similar product categories.
Learning Objective:
- Frame an operational bottleneck as a machine learning task, and understand why image classification with the K Nearest Neighbors algorithm is a practical and scalable solution to a business challenge.
- Describe the basic mechanics of how computers process images, and explain how the K Nearest Neighbors algorithm leverages this numerical data to classify unseen items.
- Build a basic machine learning pipeline in Python utilizing libraries like scikit learn and torchvision to prepare the data, train the algorithm, and evaluate the model performance.
- Apply the mindset of a data analyst by exploring how data augmentation effectively using existing data to improve predictive accuracy.