Execute the BDMO Algorithm with p = 3 on the following 1-dimensional, Euclidean data:
1, 45, 80, 24, 56, 71, 17, 40, 66, 32, 48, 96, 9, 41, 75, 11, 58, 93, 28, 39, 77
The clustering algorithms is k-means with k = 3. Only the centroid of a cluster, along with its count, is needed to represent a cluster.
Using your clusters from the above, produce the best centroids in response to a query asking for a clustering of the last 10 points.
Show all calculations and steps to prove.
# Custom clustering library source("clustering_library.R") # Load in data x <- c( 1, 45, 80, 24, 56, 71, 17, 40, 66, 32, 48, 96, 9, 41, 75, 11, 58, 93, 28, 39, 77) records <- data.frame(x=x) # Cluster parameters p <- 3 k <- 3 # Break up data into buckets buckets <- initBuckets(records, 3, 2) bdmo <- lapply(buckets, function(b) { rec <- b[['records']] if (nrow(rec) > k) { km <- kmeans(rec, k) return(list(centroid = km$centers, count = length(km$cluster))) } else { return(list(centroid = rec, count = nrow(rec))) } }) for (b in bdmo) { print("Centroid:") print(t(b[['centroid']])) print print(c("Count: ", b[['count']])) print("---------------------------") }
Get Answers For Free
Most questions answered within 1 hours.