This code performs K-Means clustering analysis on the Iris dataset using R. It explores different feature combinations by varying the number of features used for clustering. For each combination, the code applies K-Means with 3 clusters and then compares the resulting cluster assignments with the actual species classifications from the Iris dataset.

kmeans_fit5 <- kmeans(iris_new[,1:2], centers = 3)
kmeans_fit5
table(kmeans_fit5$cluster, iris$Species)

kmeans_fit6 <- kmeans(iris_new[,1:3], centers = 3)
kmeans_fit6
table(kmeans_fit6$cluster, iris$Species)

kmeans_fit7 <- kmeans(iris_new[,1:4], centers = 3)
kmeans_fit7
table(kmeans_fit7$cluster, iris$Species)

kmeans_fit8 <- kmeans(iris_new[,2:3], centers = 3)
kmeans_fit8
table(kmeans_fit8$cluster, iris$Species)

kmeans_fit9 <- kmeans(iris_new[,2:4], centers = 3)
kmeans_fit9
table(kmeans_fit9$cluster, iris$Species)

kmeans_fit10 <- kmeans(iris_new[,3:4], centers = 3)
kmeans_fit10
table(kmeans_fit10$cluster, iris$Species)

The analysis aims to understand how different feature combinations influence the clustering results and their alignment with the known species classifications. By comparing the cluster assignments with the actual species labels, the effectiveness of different feature selections for K-Means clustering can be assessed.

K-Means Clustering Analysis on Iris Dataset with R

原文地址: https://www.cveoy.top/t/topic/oyP8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录