Appendix

About

This section is included to assist the students to perform the activities in the book. It includes detailed steps that are to be performed by the students to achieve the objectives of the activities.

Chapter 1: Introduction to Clustering Methods

Activity 1: k-means Clustering with Three Clusters

Solution:

  1. Load the Iris dataset in the iris_data variable:

    iris_data<-iris

  2. Create a t_color column and make its default value red. Change the value of the two species to green and blue so the third one remains red:

    iris_data$t_color='red'

    iris_data$t_color[which(iris_data$Species=='setosa')]<-'green'

    iris_data$t_color[which(iris_data$Species=='virginica')]<-'blue'

    Note

    Here, we change the color column of only those values whose species ...

Get Applied Unsupervised Learning with R now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.