boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 请教一个R:K-means的问题
相关主题
[合集] k-mean clustering
在线等,请教一个SAS关于cluster命令的输出结果问题
请教一个频率优化问题(相关性?)
k means clustering number
Urgent: Hierarchical / Kmeans Clustering Analysis in R 哪个更快?
Sample size for clustering analysis
data clustering by vector correlation distance
这种情况应该用什么hypothesis test。
用什么可以画这个clustering 图? R?
AR(1) and clustering by firms
相关话题的讨论汇总
话题: means话题: kmeans话题: centers话题: cluster话题: dist
进入Statistics版参与讨论
1 (共1页)
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)

1 (共1页)
进入Statistics版参与讨论
相关主题
AR(1) and clustering by firms
Clustered Data能用GEE或Mixed Model吗?
请问哪里有PCA的SAS code 啊
very simple question about Cluster data
怎么样estimate two-way cluster logistic regression?有包子
请教一个关于clustering的问题
求教:Cox PH 模型的cluster data处理
问一个聚类分析
包子贴请帮忙下一个程序,U Wisconsin的同学请进
关于一个预测问题
相关话题的讨论汇总
话题: means话题: kmeans话题: centers话题: cluster话题: dist