March 2019
Beginner to intermediate
464 pages
10h 57m
English
The k-means clustering algorithm is a frequently used algorithm to draw insights on the formations and separations within the data. In marketing, it is often used to build customer segments and understand the behaviors of these different segments. Let's dive into building clustering models in R.
You can build and fit a k-means clustering model using the following code:
cluster <- kmeans(normalizedDF[c("TotalSales", "OrderCount", "AvgOrderValue")], 4)
As you can see from this code, we are building a clustering model that splits the data into 4 segments. The first parameter of the kmeans function is for the data to be used for k-means clustering and the second parameter is to define the desired number of clusters. In this ...
Read now
Unlock full access