Practical 7 1
Practical 7 1
Practical 7 1
Practical 7
cl<-kmeans(new_data,3)
cl
plot(clusters)
ggplot(iris, aes(Petal.Length, Petal.Width, color = iris$Species)) +
geom_point(alpha = 0.4, size = 3.5) + geom_point(col = clusterCut1) +
scale_color_manual(values = c('black', 'red', 'green'))
Q3)
data(iris)
# Structure
str(iris)
# Installing Packages
install.packages("ClusterR")
install.packages("cluster")
# Loading package
library(ClusterR)
library(cluster)
# Confusion Matrix
cm <- table(iris$Species, kmeans.re$cluster)
cm
## Visualizing clusters
y_kmeans <- kmeans.re$cluster
clusplot(iris_1[, c("Sepal.Length", "Sepal.Width")],
y_kmeans,
lines = 0,
shade = TRUE,
color = TRUE,
labels = 2,
plotchar = FALSE,
span = TRUE,
main = paste("Cluster iris"),
xlab = "Sepal.Length",
ylab = "Sepal.Width")