You are on page 1of 1

library(plyr)

library(ggplot2)
library(cluster)
library(lattice)
library(graphics)
library(grid)
library(gridExtra)
//The Ruspini data set, consisting of 75 points in four groups that is popular f
or illustrating clustering techniques.
data()
data(ruspini)
ruspini
summary(ruspini)
//plot(fanny(ruspini, 5))
wss<- numeric(15)
for(k in 1:15) wss[k] <- sum(kmeans(ruspini, centers=k, nstart=25)$withinss)
plot(1:15, wss, type="b", xlab="Number of Clusters", ylab= "Within Sum of Square
s")
km=kmeans(ruspini,4, nstart=25)
km
plot(ruspini, col = km$cluster)
points(km$centers, col = 1:4, pch=8, cex=2)
data(iris)
str(iris)
plot(iris)
ggplot(iris, aes(Petal.Length, Petal.Width, color = Species)) + geom_point()
iris2<- iris
summary(iris2)
iris2$Species<-NULL
summary(iris2)
wss<- numeric(15)
for(k in 1:15) wss[k] <- sum(kmeans(iris2, centers=k, nstart=25)$withinss)
plot(1:15, wss, type="b", xlab="Number of Clusters", ylab= "Within Sum of Square
s")
km2=kmeans(iris2,4, nstart=25)
plot(iris2, col = km2$cluster)
points(km2$centers, col = 1:4, pch=8, cex=2)
plot(iris2[c("Sepal.Length", "Sepal.Width")], col = km2$cluster)
points(km2$centers[,c("Sepal.Length", "Sepal.Width")], col = 1:4, pch=8, cex=2)
plot(iris2[c("Sepal.Length", "Petal.Width")], col = km2$cluster)
points(km2$centers[,c("Sepal.Length", "Petal.Width")], col = 1:4, pch=8, cex=2)
irisCluster <- kmeans(iris[, 3:4], 3, nstart = 25)
table(irisCluster$cluster, iris$Species)
irisCluster$cluster <- as.factor(irisCluster$cluster)
ggplot(iris, aes(Petal.Length, Petal.Width, color = iris$cluster)) + geom_point(
)
BMW Delearship Data
http://dataminingtrend.com/weka_app/ex2/#view2
http://www.ibm.com/developerworks/library/os-weka2/
http://www.csc.villanova.edu/~matuszek/spring2015/bmw-browsers.arff

You might also like