Case Details
Patterns to Predictions: Machine Learning Foundations with K-Nearest Neighbors
A fictional telecommunications company, You Fantasy, is seeing a growing number of customers leaving its business. To proactively retain subscribers using targeted offers instead of costly blanket discounts, the marketing team needs a way to identify at-risk customers before they actually leave. In this case study, students will follow data analyst Lin Chen to solve this business problem by building a predictive machine learning model using the K-Nearest Neighbors (KNN) algorithm. Following Chen's thought process, students will first work through a simplified example to build intuition around KNN's core logic: predicting an active customer's future behavior based on the known outcomes of their most similar past "neighbors". More specifically, students will learn the underlying mathematical concepts of distance calculation and gain hands-on experience by writing functional Python code. Students will utilize libraries like scikit-learn and pandas to build, train, and test their own predictive pipelines, ultimately understanding how predictive models can solve real-life business problems.
Learning Objective:
- Translate a business challenge into a predictive machine learning task, and understand why complex data requires flexible algorithms like K-Nearest Neighbors (KNN) instead of simple linear rules.
- Prepare data for distance-based modeling, understanding why techniques like feature scaling and categorical encoding are necessary to ensure accurate predictions.
- Tune the model by adjusting basic settings such as the number of neighbors (K) and distance weighting, and explain how these choices affect the algorithm's predictions.
- Build a basic machine learning pipeline in Python, and evaluate the model’s performance by comparing its accuracy against a simple baseline.