Last active
February 1, 2020 03:45
-
-
Save adammb86/25333660998d0846e14e7a7711f417f9 to your computer and use it in GitHub Desktop.
Ujicoba Algoritma K-Means
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Siswa | Matematika | IPA | IPS | |
---|---|---|---|---|
1 | 2 | 4 | 8 | |
2 | 10 | 8 | 1 | |
3 | 6 | 2 | 1 | |
4 | 8 | 9 | 10 | |
5 | 4 | 4 | 8 | |
6 | 7 | 8 | 3 | |
7 | 4 | 5 | 4 | |
8 | 2 | 10 | 6 | |
9 | 7 | 7 | 8 | |
10 | 4 | 8 | 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
datanilai<-read.csv(file.choose(),header = TRUE) | |
datanilai<-as.data.frame(datanilai) | |
(datanilaiready<-data.frame(datanilai$Matematika,datanilai$IPA,datanilai$IPS)) | |
summary(datanilaiready) | |
#Percobaan seluruh algoritma di K-Means | |
(hasilkmeans<-kmeans(datanilaiready,2,algorithm = "Hartigan-Wong")) | |
(hasilkmeans<-kmeans(datanilaiready,2,algorithm = "Lloyd")) | |
(hasilkmeans<-kmeans(datanilaiready,2,algorithm = "Forgy")) | |
(hasilkmeans<-kmeans(datanilaiready,2,algorithm = "MacQueen")) | |
#melihat hasil pemetaan data nilai siswa per cluster | |
table(datanilai$Siswa, hasilkmeans$cluster) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment