i********f 发帖数: 206 | 1 我有一些数据,例如
x y
[1,] 0.010313070 -0.02893566
[2,] 0.245346732 0.31654765
[3,] 0.549282428 -0.15341703
[4,] -0.208582213 0.29955670
我想把他们分成两组.
> cl <- kmeans(dist,2)
如果我想固定K-means的起始点,让他们分别是([1,] 0.010313070 -0.02893566)和([2
,] 0.245346732 0.31654765),应该怎么写k-means中那个centers的参数呢? 多谢 | o****o 发帖数: 8077 | 2 use centers= argument in the kmeans function
2 vectors will result in 2 clusters | i********f 发帖数: 206 | 3 我不清楚怎么写这个,
总是被提示列数必须相等.
能给个例子么?多谢了
【在 o****o 的大作中提到】 : use centers= argument in the kmeans function : 2 vectors will result in 2 clusters
| o****o 发帖数: 8077 | 4 use rbind to stack the two vectors:
#--------------------
> x = read.table("clipboard",sep=' ', as.is=T, header=F) #read in sample
data
> c1<-c(0.010313070, -0.02893566)
> c2<-c(0.245346732, 0.31654765)
> kmeans(x, centers=c(c1, c2))
K-means clustering with 2 clusters of sizes 3, 1
Cluster means:
V1 V2
1 0.01569253 0.1957229
2 0.54928243 -0.1534170
Clustering vector:
[1] 1 1 2 1
Within cluster sum of squares by cluster:
[1] 0.1789207 0.0000000
Available components:
[1] "clust
【在 i********f 的大作中提到】 : 我不清楚怎么写这个, : 总是被提示列数必须相等. : 能给个例子么?多谢了
| i********f 发帖数: 206 | 5 对的,是rbind,多谢多谢,呵呵
【在 o****o 的大作中提到】 : use rbind to stack the two vectors: : #-------------------- : > x = read.table("clipboard",sep=' ', as.is=T, header=F) #read in sample : data : > c1<-c(0.010313070, -0.02893566) : > c2<-c(0.245346732, 0.31654765) : > kmeans(x, centers=c(c1, c2)) : K-means clustering with 2 clusters of sizes 3, 1 : Cluster means: : V1 V2
| i********f 发帖数: 206 | 6 在用Kmeans的时候,有人会用dist处理matrix,然后再输入到Kmeans,
有人好像直接就用最初的matrix,直接运行Kmeans
这两个有什么区别么,对最后的结果而言
【在 o****o 的大作中提到】 : use rbind to stack the two vectors: : #-------------------- : > x = read.table("clipboard",sep=' ', as.is=T, header=F) #read in sample : data : > c1<-c(0.010313070, -0.02893566) : > c2<-c(0.245346732, 0.31654765) : > kmeans(x, centers=c(c1, c2)) : K-means clustering with 2 clusters of sizes 3, 1 : Cluster means: : V1 V2
| o****o 发帖数: 8077 | 7 distance measures dissimilarity
raw matrix measures Eucleadian distance (L-2)
【在 i********f 的大作中提到】 : 在用Kmeans的时候,有人会用dist处理matrix,然后再输入到Kmeans, : 有人好像直接就用最初的matrix,直接运行Kmeans : 这两个有什么区别么,对最后的结果而言
| i********f 发帖数: 206 | 8 多谢,呵呵
【在 o****o 的大作中提到】 : distance measures dissimilarity : raw matrix measures Eucleadian distance (L-2)
|
|
|