Skip to Main Content
R Projects For Dummies
book

R Projects For Dummies

by Joseph Schmuller
February 2018
Beginner content levelBeginner
360 pages
7h 4m
English
For Dummies
Content preview from R Projects For Dummies

Chapter 10

K-Means Clustering

IN THIS CHAPTER

check Mastering k-means clustering

check k-means clustering irises in R

check k-means clustering the glass data set

In unsupervised learning, a machine learning (ML) process looks for structure in a data set. The objective is to find patterns, not make predictions. One way to structure a data set is to put the data points into subgroups called clusters. The trick is to find a recipe for creating the clusters. One such recipe is called k-means clustering.

How It Works

To introduce k-means clustering, I show you how to work with the iris data frame, as I have in previous chapters. This is the iris data frame that's in the base R installation. Fifty flowers in each of three iris species (setosa, versicolor, and virginica) make up the data set. The data frame columns are Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, and Species.

For this discussion, you're concerned with only Petal.Length, Petal.Width, and Species. That way, you can visualize the data in two dimensions.

Figure 10-1 plots the iris data frame with Petal.Length on the x-axis, Petal.Width on the y-axis, and Species as the color of the plotting character. (For the ggplot details, see ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

R Data Analysis Projects

R Data Analysis Projects

Mark Hodnett, Gopi Subramanian

Publisher Resources

ISBN: 9781119446187Purchase book