#------------------ # Data Preparation #------------------ #Read datasets #Download the data from http://www.saedsayad.com/datasets/BikeRental.zip train <- read.csv("bike_rental_train.csv") test <- read.csv("bike_rental_test.csv") #Rows and Cols dim(train) dim(test) #Columns name colnames(train) colnames(test) #Show head(train) head(test) #Rows and Cols dim(train) dim(test) #Columns name colnames(train) colnames(test) #Show head(train) head(test) #------------------------- # Hierarchical Clustering #------------------------- library(ggplot2) #Clusters clusters <- hclust(dist(train), method='complete') plot(clusters) #Top 4 clusters clusterCut <- cutree(clusters, 4) ggplot(train, aes(temp, humidity)) + geom_point(size = 1) + geom_point(col = clusterCut) + scale_color_manual(values = c('black', 'red', 'green', 'blue'))