R-“原理计算”只能与比变量更多的单位一起使用
我正在使用 R 软件(R Commander)对我的数据进行聚类。我的数据有一个较小的子集,包含 200 行和大约 800 列。尝试 kmeans 聚类并在图表上绘制时出现以下错误。 “‘princomp’只能与比变量更多的单位一起使用”
然后我创建了一个 10 行和 10 列的测试文档,它绘制得很好,但是当我添加额外的列时,我再次收到错误。 这是为什么呢?我需要能够绘制我的集群。当我在对数据集执行 kmeans 后查看数据集时,我可以看到额外的结果列,其中显示它们属于哪些集群。
我做错了什么吗,我可以摆脱这个错误并绘制更大的样本吗??? 请帮忙,已经让我头疼了一个星期了。 谢谢你们。
I am using R software (R commander) to cluster my data. I have a smaller subset of my data containing 200 rows and about 800 columns. I am getting the following error when trying kmeans cluster and plot on a graph.
"'princomp' can only be used with more units than variables"
I then created a test doc of 10 row and 10 columns whch plots fine but when I add an extra column I get te error again.
Why is this? I need to be able to plot my cluster. When I view my data set after performing kmeans on it I can see the extra results column which shows which clusters they belong to.
IS there anything I am doing wrong, can I ger rid of this error and plot my larger sample???
Please help, been wrecking my head for a week now.
Thanks guys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题在于变量多于样本点,并且正在进行的主成分分析失败。
在
princomp
的帮助文件中,它解释了(阅读?princomp
):The problem is that you have more variables than sample points and the principal component analysis that is being done is failing.
In the help file for
princomp
it explains (read?princomp
):如果样本少于数据点,则主成分分析未指定。
每个数据点都将是它自己的主要组成部分。为了使 PCA 发挥作用,实例的数量应明显大于维度的数量。
简单来说,你可以这样看待问题:
如果您有
n
维度,则可以使用全部为0
或最多具有一个的向量对最多
。而且这是最优的,所以 PCA 就会这样做!但这并没有多大帮助。n+1
个实例进行编码>1Principal component analysis is underspecified if you have fewer samples than data point.
Every data point will be it's own principal component. For PCA to work, the number of instances should be significantly larger than the number of dimensions.
Simply speaking you can look at the problems like this:
If you have
n
dimensions, you can encode up ton+1
instances using vectors that are all0
or that have at most one1
. And this is optimal, so PCA will do this! But it is not very helpful.您可以使用 prcomp 代替 princomp
you can use prcomp instead of princomp