From the course: Data Science Foundations: Data Mining in Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

K-means

K-means - Python Tutorial

From the course: Data Science Foundations: Data Mining in Python

Start my 1-month free trial

K-means

- [Instructor] Sometimes, you know how many groups there are. And sometimes you know that those are the clusters that you want to use. In that case, instead of doing hierarchical clustering which shows you every possible level of clustering you use k-Means which allows you to specify how many groups there should be, where the number of groups is K. And this is a very common method as well. You can think of it as something for instance, that is also used in marketing research where you know how many campaigns you can run and you need to find groups that fall into each of those. So k-Means is a very useful, frequently used approach. And let me show you how to do this in Python. We're going to start by loading a number of libraries and several functions here you see from Psychic Learn. Let's load those. And then I'm going to read the data from the CSV file split out the class variable into Y, standardize the other variables…

Contents