- Applied Unsupervised Learning with R
- Alok Malik Bradford Tuckfield
- 348字
- 2021-06-11 13:35:35
Introduction to the Iris Dataset
In this chapter, we're going to use the Iris flowers dataset in exercises to learn how to classify three species of Iris flowers (Versicolor, Setosa, and Virginica) without using labels. This dataset is built-in to R and is very good for learning about the implementation of clustering techniques.
Note that in our exercise dataset, we have final labels for the flowers. We're going to compare clustering results with those labels. We choose this dataset just to demonstrate that the results of clustering make sense. In the case of datasets such as the wholesale customer dataset (covered later in the book), where we don't have final labels, the results of clustering cannot be objectively verified and therefore might lead to misguided conclusions. That's the kind of use case where clustering is used in real life when we don't have final labels for the dataset. This point will be clearer once you have done both the exercises and activities.
Exercise 1: Exploring the Iris Dataset
In this exercise, we're going to learn how to use the Iris dataset in R. Assuming you already have R installed in your system, let's proceed:
- Load the Iris dataset into a variable as follows:
iris_data<-iris
- Now that our Iris data is in the iris_data variable, we can have a look at its first few rows by using the head function in R:
head(iris_data)
The output is as follows:
Figure 1.4: The first six rows of the Iris dataset
We can see our dataset has five columns. We're mostly going to use two columns for ease of visualization in plots of two dimensions.
Types of Clustering
As stated previously, clustering algorithms find natural groupings in data. There are many ways in which we can find natural groupings in data. The following are the methods that we're going to study in this chapter:
- k-means clustering
- k-medoids clustering
Once the concepts related to the basic types of clustering are clear, we will have a look at other types of clustering, which are as follows:
- k-modes
- Density-based clustering
- Agglomerative hierarchical clustering
- Divisive clustering