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.

Solution: K-means

Solution: K-means - Python Tutorial

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

Start my 1-month free trial

Solution: K-means

(upbeat music) - [Narrator] Now that you've had a moment let's see how we can use k-MEANS with the new dataset, the iris dataset. As before, I'm going to load a number of packages and then following the template that we had when we did k-MEANS on the penguins dataset, then we'll load the dataset from the local CSV file and take a look we have four physical measurements on different scales and we have a species variable. Well, I'm going to rename species as y, remove it from the original, save it on its own, standardize the other variables and take a look again at the first few rows. And now what we see are Z scores, these are all done so that they have a mean of zero and a standard deviation of one, and we've saved the class variable which gives us the species in a separate object lowercase y. Now let's do k-MEANS and we use the same code that we had before, that's one of the advantages of standardized names for objects.…

Contents