Find k
set.seed(7)
total_withinss <- c()
for (i in 1:8) {
kproto <- clustMixType::kproto(iris,
k = i,
nstart = 25)
total_withinss[i] <- kproto$tot.withinss
}
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## Estimated lambda: 1.714859
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## Estimated lambda: 1.714859
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## Estimated lambda: 1.714859
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## Estimated lambda: 1.714859
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## Estimated lambda: 1.714859
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## Estimated lambda: 1.714859
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## Estimated lambda: 1.714859
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## Estimated lambda: 1.714859
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
## [1] 852.85649 238.09090 87.95509 67.44546 51.15272 42.89405 35.62459
## [8] 33.28501
# identify ELBOW
tibble(k = 1:length(total_withinss),
total_error = total_withinss
) %>%
ggplot(aes(x = k,
y = total_error)
) +
geom_point(size = 2) +
geom_line() +
theme_bw() +
labs(x = "Number of Clusters",
y = "tot.withinss") +
geom_text(x = 3,
y = total_withinss[3],
label = "ELBOW",
alpha = 0.5,
color = "blue",
size = 5)

Cluster
iris_kproto <- iris %>%
clustMixType::kproto(k = 3,
nstart = 25)
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## Estimated lambda: 1.714859
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
##
## # NAs in variables:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 0 0 0 0 0
## 0 observation(s) with NAs.
## Numeric predictors: 4
## Categorical predictors: 1
## Lambda: 1.714859
##
## Number of Clusters: 3
## Cluster sizes: 50 49 51
## Within cluster error: 15.151 39.15551 33.64858
##
## Cluster prototypes:
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.006000 3.428000 1.462000 0.246000 setosa
## 2 6.622449 2.983673 5.573469 2.032653 virginica
## 3 5.915686 2.764706 4.264706 1.333333 versicolor
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
## 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3
## 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
## 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
## 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
## 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2
## 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
## 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
## 141 142 143 144 145 146 147 148 149 150
## 2 2 2 2 2 2 2 2 2 2
## clusters
## 1 2 3
## 50 49 51
Append 3-Prototypes Clustering assigments to dataset
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
## 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3
## 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
## 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
## 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
## 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2
## 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
## 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
## 141 142 143 144 145 146 147 148 149 150
## 2 2 2 2 2 2 2 2 2 2
iris1 <- iris %>%
mutate(kproto_cluster = iris_kproto$cluster)
iris1 %>%
glimpse()
## Rows: 150
## Columns: 6
## $ Sepal.Length <dbl> 5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6, 5.0, 4.4, 4.9, 5.4, …
## $ Sepal.Width <dbl> 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1, 3.7, …
## $ Petal.Length <dbl> 1.4, 1.4, 1.3, 1.5, 1.4, 1.7, 1.4, 1.5, 1.4, 1.5, 1.5, …
## $ Petal.Width <dbl> 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, …
## $ Species <fct> setosa, setosa, setosa, setosa, setosa, setosa, setosa,…
## $ kproto_cluster <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…