- 20150827 [學習筆記] R與資料探勘 (4)
- 整理自 R軟體與資料探勘之開發與應用 -- 階層分群、k平均、模糊c平均
- [ GitHub ]
- (六)階層分群演算法(Hierarchical Clustering)
- [前置作業] 基本概念
- STAGE 1 : 輸入資料和運算階段
- STAGE 2 : 評估階段
- (七)k平均演算法(k-Means)
- [前置作業] 基本概念
- STAGE 1 : 輸入資料和運算階段
- STAGE 2 : 評估階段
- (八)模糊c平均演算法(Fuzzy c-Means)
- [前置作業] 基本概念
- STAGE 1 : 輸入資料和運算階段
- STAGE 2 : 評估階段
Visible to members of this folder
整理自 R軟體與資料探勘之開發與應用 -- 階層分群、k平均、模糊c平均
R 軟體安裝(略過)R Studio軟體安裝(略過)START : 訓練資料和測試資料(完成)(一)倒傳遞類神經網路(Back-Propagation Neural Network)(完成)(二)決策樹(Decision Tree)(三)支援向量機(Support Vector Machine)(完成)(四)貝式分類(Naïve Bayes)(五)k位最近鄰居法(k-Nearest Neighbor)(六)階層分群演算法(Hierarchical Clustering)
# input data
inputdata <- read.csv(file.choose())
# computation
hc.model <- hclust(dist(inputdata), method="ave")
print(hc.model)
# evaluation
plot(hc.model, hang = -1, labels=inputdata$Species)
(七)k平均演算法(k-Means)
# input data
inputdata <- read.csv(file.choose())
# computation
km.model <- kmeans(inputdata, 3)
print(km.model)
# evaluation
table(inputdata$Species, km.model$cluster)
plot(inputdata[c("Sepal.Length", "Sepal.Width")], col=km.model$cluster)
points(km.model$centers[,c("Sepal.Length", "Sepal.Width")],
col=1:3, pch=8, cex=2)
(八)模糊c平均演算法(Fuzzy c-Means)
library(e1071)
# input data
inputfile <- read.csv(file.choose())
inputdata <- subset(inputfile, select = -Species)
# computation
cm.model <- cmeans(inputdata, 3, 100, m=2,method="cmeans")
print(cm.model)
# evaluation
table(inputfile$Species, cm.model$cluster)
plot(inputdata[,1], inputdata[,2], col=cm.model$cluster)