Unlocking Real-World Insights: Master K-Means and KNN through Practical Use Cases

Deepak rkm
3 min readMar 31, 2024

Given: We have huge customer shopping data.

When: Business owners would like to have some actionable insights that can help to improve the business in terms of revenue

Then: Create a Model which can help to extract the details starting with the steps from inputting shopping data either through K means or KNN

What’s next: let’s try to solve the above use case through k means and KNN.

Before let’s understand some fundamental points of both

What is K means:

Unsupervised learning algorithm used for clustering that partitions data into K distinct clusters based on feature similarity.

When to Use K means

When you need to discover inherent groupings within your data.

When you have a large dataset and need a fast and scalable clustering method.

When the data is numeric since K-Means relies on mathematical means for clustering, which may not be applicable for categorical data.

Use case example: Customer Segmentation, Image segmentation, surveillance, Data preprocessing.

Implementation of flow diagram for the shopping data for K means:

K means Flow diagram for the Shopping data use case

--

--

Deepak rkm

proud to be pythonist and aspiring to be sre with AI skills