模糊c均值聚类(FCM)

时间:2016-01-30 00:26:59

标签: r cluster-analysis package

从这两个模糊c均值聚类的结果:

x=data.frame(v1=c(85 ,99 ,89 ,89 ,99),
v2=c(97 ,90 ,93 ,97 ,90),
v3=c( 85 ,91 ,87 ,91 ,93))


 x
  v1 v2 v3
1 85 97 85
2 99 90 91
3 89 93 87
4 89 97 91
5 99 90 93

1-运行FCM而不使用rbind:

install.packages("e1071")
library("e1071")

result1<-cmeans(x,2,50,verbose=TRUE,method="cmeans")
result1

Fuzzy c-means clustering with 2 clusters

Cluster centers:
        v1       v2       v3
1 98.91535 90.04707 91.97589
2 87.60772 95.65459 87.56601

Memberships:
              1           2
[1,] 0.04968228 0.950317721
[2,] 0.99448901 0.005510993
[3,] 0.06595119 0.934048808
[4,] 0.09525480 0.904745200
[5,] 0.99449849 0.005501515

Closest hard clustering:
[1] 2 1 2 2 1

Available components:
[1] "centers"     "size"        "cluster"     "membership"  "iter"        "withinerror" "call"       

使用rbind运行FCM:

  y<-rbind(x$v1,x$v2,x$v3)
  result2<-cmeans(y,2,50,verbose=TRUE,method="cmeans")
  result2

Fuzzy c-means clustering with 2 clusters

Cluster centers:
     [,1]     [,2]     [,3]     [,4]     [,5]
1 96.7755 90.04519 92.89437 96.88113 90.07599
2 85.0000 95.29537 88.07384 89.92616 96.22153

Memberships:
              1           2
[1,] 0.05805512 0.941944884
[2,] 0.99970715 0.000292848
[3,] 0.12524508 0.874754919

Closest hard clustering:
[1] 2 1 2

Available components:
[1] "centers"     "size"        "cluster"     "membership"  "iter"        "withinerror" "call"       

我的问题是rbind是否需要运行FCM?另一种方式,对于使用或不使用rbind的运行FCM,结果是正确的。

1 个答案:

答案 0 :(得分:1)

正如?cmeans告诉你的那样,函数的第一个参数应该是

  

[t]数据矩阵,其中列对应于变量和行   观察结果。

因此,如果您有三个变量和五个观察值,cmeans(x,2,50,verbose=TRUE,method="cmeans")将为您提供 - 除其他外 - 您的五个观察值的成员资格值。即:观察/行2和5属于集群1,1,3,4属于集群2(您请求了2集群解决方案)。

第二种方法对我没有任何意义;单独因为没有x$v4而没有x$v5

相关问题