Demo entry 6679807

K-Mean

   

Submitted by anonymous on Dec 06, 2017 at 17:57
Language: Python. Code size: 786 Bytes.

set.seed(10086)
kmean.test=kmeans(test.salary,5)
library(kableExtra)
names(kmean.test) 
summary(kmean.test) %>% 
  knitr::kable("html") %>%
  kable_styling()
png('kmeans_clust2.png',
    width     = 5,
    height    = 3,
    units     = "in",
    res       = 1200,
    pointsize = 4)
par(mfrow=c(1,1))
plot(log10(test.salary$aa)~test.salary$a.occu,
     col=kmean.test$cluster, 
     main ="k-nearest neighbor clustering",
     cex=2,
     ylab="Log10 Mean Annual Salary",
     xlab="Occupation")
with(test.salary, text(log10(test.salary$aa)~test.salary$a.occu, labels = detailed.occu.project[,4], pos = c(1,3), cex=0.75, col = "darkgray"))
points(log10(test.salary$aa)~test.salary$a.occu,
       col=kmean.test$cluster,
       pch=16,
       cex=2)
dev.off()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).